chore: fix missing node_modules in lambda zip v2#248
Merged
ava-silver merged 8 commits intoMay 6, 2026
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #248 +/- ##
=======================================
Coverage 82.72% 82.72%
=======================================
Files 19 19
Lines 938 938
Branches 231 231
=======================================
Hits 776 776
Misses 91 91
Partials 71 71 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
nina9753
approved these changes
May 6, 2026
avangelillo
approved these changes
May 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

What does this PR do?
Fixes the macro Lambda zip missing
node_modules/(issue #242). Two changes:Inlines the install step into
build. yarn berry does NOT auto-run arbitrarypre/posthooks (only well-known lifecycle scripts likeprepare,postinstall). PR [SVLS-8827] upgrade to yarn berry and add npm minimal age gate #238's yarn berry migration silently broke thepostbuildhook so the install step never ran in any environment. New build script:tsc && cp package.json dist/package.json && npm install --omit=dev --prefix dist.Replaces the false-positive CI check with one that actually inspects the zip. The previous check (
cd dist && node -e "require('./src/index.js')") always passed because Node's module resolution walked up fromdist/intoserverless/node_modules/(populated byyarn install) and foundloglevelthere — even whendist/node_modules/was empty. The new check zipsdist/, extracts to a clean/tmp/directory (no parentnode_modules/to fall back to), and runs the require there.Motivation
v0.27.1 still ships a broken Lambda. PR #244 changed the
postbuildscript and added a "verify Lambda bundle" step that both passed CI and shipped — but neither actually did anything: the postbuild was dead code under yarn berry, and the verify step was finding deps in the parent's node_modules. See #242 and the ZD ticket for customer reports.Testing Guidelines
cd serverless && rm -rf dist && yarn build→ confirmdist/node_modules/loglevelanddist/node_modules/@aws-sdk/existProof
CI:
Cannot find module 'loglevel'from extracted zip, exact production error.End-to-end against real AWS + Datadog (US1, sandbox account 425362996713):
ava-silver-macro-fix242inus-east-1— noCannot find module 'loglevel'failure on the macro Lambda's cold start (this is the regression we fixed).ava-fix242-hello-stackwithTransform: DatadogServerless. The macro instrumented the function as expected: Datadog-Node22 layer v132 + Datadog-Extension layer v92, handler rewritten to/opt/nodejs/node_modules/datadog-lambda-js/handler.handler, allDD_*env vars set.ava-fix242-hello20+ times. Lambda logs show the extension running cleanly and successfully flushing traces:DD_EXTENSION | DEBUG | Request succeeded status=202 Acceptedforhttps://trace.agent.datadoghq.com/api/v0.2/traces.https://ddserverless.datadoghq.com/apm/trace/<id>(US1 org corresponding to the API key used):4986331605483463556,6788063569943029167,8662992718378330393.Types of changes
Check all that apply