fix: avoid hardcoded override to avoid durable function failure#13354
fix: avoid hardcoded override to avoid durable function failure#13354lauhon wants to merge 2 commits intoserverless:mainfrom
Conversation
📝 WalkthroughWalkthroughThe dev command's runtime assignment was updated to use the local Node.js version dynamically instead of enforcing nodejs20.x. This allows projects requiring higher Node versions, such as nodejs22.x for durable functions, to function correctly during development. Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~2 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
|
All contributors have signed the CLA ✍️ ✅ |
|
I have read the CLA Document and I hereby sign the CLA |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
packages/serverless/lib/plugins/aws/dev/index.js (1)
286-288:⚠️ Potential issue | 🟡 MinorStale JSDoc — update step 3 to reflect the dynamic runtime.
The comment at step 3 still reads
'nodejs20.x' as expected by the shim, but the runtime is now derived from the local Node.js version.📝 Proposed fix
- * 3. Update all AWS Lambda functions' runtime to 'nodejs20.x' as expected by the shim + * 3. Update all AWS Lambda functions' runtime to match the local Node.js runtime (e.g. nodejs22.x) as expected by the shim🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/serverless/lib/plugins/aws/dev/index.js` around lines 286 - 288, Update the stale JSDoc step 3 that currently says "'nodejs20.x' as expected by the shim" to state that the Lambda runtime is determined dynamically from the local Node.js version (e.g., "runtime is derived from the local Node.js version") so it matches the implementation that computes the runtime; search the file for the JSDoc block containing the bullet list and the literal 'nodejs20.x' (step 3) and replace that phrase accordingly so the comment reflects the dynamic runtime behavior.
🧹 Nitpick comments (1)
packages/serverless/lib/plugins/aws/dev/index.js (1)
332-333:localRuntimeis not validated against supported AWS Lambda Node.js runtimes.
process.version.split('.')[0].replace('v', '')correctly extracts the major version, but AWS Lambda only supports specific Node.js runtimes (nodejs18.x,nodejs20.x,nodejs22.x). If a developer's local Node.js is an odd/unstable release (e.g., 21 or 23),functionConfig.runtimeis set to an unsupported value and the subsequentdeployspawn will fail with an opaque AWS error rather than a clear, actionable message.Consider validating — or at minimum warning — before proceeding:
🛡️ Proposed improvement
const localRuntimeVersion = process.version.split('.')[0].replace('v', '') const localRuntime = `nodejs${localRuntimeVersion}.x` + const supportedNodeRuntimes = ['nodejs18.x', 'nodejs20.x', 'nodejs22.x'] + if (!supportedNodeRuntimes.includes(localRuntime)) { + throw new ServerlessError( + `Dev mode requires a locally installed Node.js version that matches a supported AWS Lambda runtime. ` + + `Your local version (${localRuntime}) is not supported. Supported runtimes: ${supportedNodeRuntimes.join(', ')}.`, + 'DEV_MODE_UNSUPPORTED_LOCAL_RUNTIME', + { stack: false }, + ) + }Also applies to: 397-397
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/serverless/lib/plugins/aws/dev/index.js` around lines 332 - 333, Extracting major Node.js version into localRuntimeVersion and building localRuntime may produce unsupported AWS Lambda runtimes (e.g., nodejs21.x); update the logic around localRuntimeVersion/localRuntime and where functionConfig.runtime is assigned to validate against the allowed set ['nodejs18.x','nodejs20.x','nodejs22.x'] and if the computed runtime is not in that set either (a) throw or return a clear, actionable error message indicating the unsupported local Node version and listing supported runtimes, or (b) emit a warning and map/fallback to the nearest supported runtime before proceeding; make this validation happen before the deploy spawn so the failure is surfaced early and references functionConfig.runtime, localRuntimeVersion, and localRuntime when reporting the issue.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@packages/serverless/lib/plugins/aws/dev/index.js`:
- Around line 286-288: Update the stale JSDoc step 3 that currently says
"'nodejs20.x' as expected by the shim" to state that the Lambda runtime is
determined dynamically from the local Node.js version (e.g., "runtime is derived
from the local Node.js version") so it matches the implementation that computes
the runtime; search the file for the JSDoc block containing the bullet list and
the literal 'nodejs20.x' (step 3) and replace that phrase accordingly so the
comment reflects the dynamic runtime behavior.
---
Nitpick comments:
In `@packages/serverless/lib/plugins/aws/dev/index.js`:
- Around line 332-333: Extracting major Node.js version into localRuntimeVersion
and building localRuntime may produce unsupported AWS Lambda runtimes (e.g.,
nodejs21.x); update the logic around localRuntimeVersion/localRuntime and where
functionConfig.runtime is assigned to validate against the allowed set
['nodejs18.x','nodejs20.x','nodejs22.x'] and if the computed runtime is not in
that set either (a) throw or return a clear, actionable error message indicating
the unsupported local Node version and listing supported runtimes, or (b) emit a
warning and map/fallback to the nearest supported runtime before proceeding;
make this validation happen before the deploy spawn so the failure is surfaced
early and references functionConfig.runtime, localRuntimeVersion, and
localRuntime when reporting the issue.
Closes: #13355
Summary by CodeRabbit
Release Notes