Skip to content

Comments

fix: avoid hardcoded override to avoid durable function failure#13354

Open
lauhon wants to merge 2 commits intoserverless:mainfrom
lauhon:patch-1
Open

fix: avoid hardcoded override to avoid durable function failure#13354
lauhon wants to merge 2 commits intoserverless:mainfrom
lauhon:patch-1

Conversation

@lauhon
Copy link

@lauhon lauhon commented Feb 18, 2026

Closes: #13355

Summary by CodeRabbit

Release Notes

  • Improvements
    • The serverless development plugin now dynamically detects and uses your local Node.js runtime version instead of enforcing a fixed version, ensuring better compatibility with your development environment.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 18, 2026

📝 Walkthrough

Walkthrough

The 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

Cohort / File(s) Summary
Runtime Environment
packages/serverless/lib/plugins/aws/dev/index.js
Changed hardcoded nodejs20.x runtime to dynamic localRuntime based on current Node.js version for dev environment compatibility.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Poem

🐰 A hop and a skip, the runtime's now free,
No longer locked down to version twenty,
Local Node.js takes the wheel with grace,
Durable functions find their rightful place!
The dev command hops with the system's own pace ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: removing a hardcoded Node.js 20 runtime override that was causing durable function failures.
Linked Issues check ✅ Passed The code change replaces hardcoded 'nodejs20.x' with dynamic localRuntime, directly addressing the core requirement in #13355 to prevent runtime override for durable functions.
Out of Scope Changes check ✅ Passed The change is narrowly scoped to fixing the runtime assignment logic in the dev command, directly related to the linked issue with no extraneous modifications.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Mmarzex
Copy link
Contributor

Mmarzex commented Feb 18, 2026

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues
Code Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@github-actions
Copy link

github-actions bot commented Feb 18, 2026

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@lauhon lauhon marked this pull request as ready for review February 18, 2026 11:49
@lauhon
Copy link
Author

lauhon commented Feb 18, 2026

I have read the CLA Document and I hereby sign the CLA

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 | 🟡 Minor

Stale 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: localRuntime is 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.runtime is set to an unsupported value and the subsequent deploy spawn 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

serverless dev fails for durable functions

2 participants