Skip to content

Comments

feat(dev-mode): match shim runtime to local Node.js version#13362

Merged
czubocha merged 1 commit intomainfrom
sc-3833
Feb 19, 2026
Merged

feat(dev-mode): match shim runtime to local Node.js version#13362
czubocha merged 1 commit intomainfrom
sc-3833

Conversation

@czubocha
Copy link
Contributor

@czubocha czubocha commented Feb 19, 2026

Summary

  • Match the dev mode shim's AWS Lambda runtime to the developer's local Node.js version instead of always hardcoding nodejs20.x
  • Fall back to nodejs20.x with a warning when the local Node.js version is not yet supported by AWS Lambda
  • Define a separate AWS_LAMBDA_SUPPORTED_NODE_RUNTIMES list (18.x, 20.x, 22.x, 24.x) in packages/serverless/lib/plugins/aws/dev/index.js, decoupled from the local-lambda wrapper's broader runtime support list (which also includes deprecated 14.x/16.x)
  • Suppress the runtime mismatch warning when the unsupported-runtime fallback warning already fires, avoiding confusing duplicate warnings
  • Extract inline runtime versions array into a named SUPPORTED_NODE_RUNTIMES const in packages/serverless/lib/plugins/aws/dev/local-lambda/index.js for readability

Test plan

  • Added test: shim runtime matches local Node.js version when it is supported by AWS Lambda (e.g., local v22 → nodejs22.x)
  • Added test: shim falls back to nodejs20.x with a single warning when local version is unsupported (e.g., local v26)
  • All 33 dev-related unit tests pass (dev.test.js + local-lambda.test.js)

Closes #13355

Summary by CodeRabbit

  • Bug Fixes

    • Enhanced Node.js runtime compatibility. Functions now deploy using your local Node.js version when supported by AWS Lambda, with intelligent fallback to nodejs20.x for unsupported versions and appropriate warning messages.
  • Tests

    • Added comprehensive test coverage for runtime selection and fallback scenarios.

Note

Low Risk
Behavior is limited to Dev Mode shim configuration and logging, with added unit coverage; main risk is unexpected runtime selection for edge Node versions.

Overview
Dev Mode no longer hardcodes the shim runtime to nodejs20.x; it now selects the local Node.js major version as the Lambda runtime when it’s in an allowlist, otherwise falls back to nodejs20.x and emits a single warning explaining the fallback.

Runtime mismatch warnings are refined to avoid duplicate/confusing messaging when the fallback path is taken, local-lambda runtime wrapper versions are refactored into a named SUPPORTED_NODE_RUNTIMES constant, and unit tests add coverage for the supported-runtime and unsupported-runtime fallback scenarios (including logger warning assertions).

Written by Cursor Bugbot for commit 9dc6083. This will update automatically on new commits. Configure here.

@Mmarzex
Copy link
Contributor

Mmarzex commented Feb 19, 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.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 19, 2026

📝 Walkthrough

Walkthrough

The changes introduce centralized AWS Lambda Node.js runtime support constants and update the serverless dev command to use the local Node.js version when compatible with Lambda, falling back to nodejs20.x with warnings when not supported. This enables durable functions requiring Node 22+ to run correctly in dev mode.

Changes

Cohort / File(s) Summary
Runtime Support Constants
packages/serverless/lib/plugins/aws/dev/index.js, packages/serverless/lib/plugins/aws/dev/local-lambda/index.js
Introduced AWS_LAMBDA_SUPPORTED_NODE_RUNTIMES and SUPPORTED_NODE_RUNTIMES constants to enumerate supported Lambda Node.js runtimes, centralizing runtime version management across dev plugin components.
Dev Command Runtime Logic
packages/serverless/lib/plugins/aws/dev/index.js
Computed runtimeForShim to use local Node.js version if supported, otherwise fallback to nodejs20.x. Added conditional warnings for runtime mismatches and fallback scenarios when updating function configurations.
Test Coverage
packages/serverless/test/unit/lib/plugins/aws/dev.test.js
Enhanced test setup with shared mockLogger, process.version manipulation helpers, and new test suite validating AwsDev.update() behavior for supported (Node 22) and unsupported (Node 26) runtimes with appropriate fallback and warning logic.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • eahefnawy

Poem

A rabbit hops through runtimes with glee, 🐰
From version twenty-two to twenty-three,
When durable functions need Node's latest might,
The dev command now gets the version right!
No more fallbacks without a warning call,
Supported runtimes handled once and for all. ✨

🚥 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 clearly and specifically summarizes the main change: matching the shim runtime to the local Node.js version instead of hardcoding nodejs20.x.
Linked Issues check ✅ Passed The PR directly addresses issue #13355 by matching dev-mode shim runtime to local Node.js version, enabling durable functions (Node >= 22) to work correctly in dev mode with proper fallback and warnings.
Out of Scope Changes check ✅ Passed All changes are scoped to the stated objective: runtime selection logic in dev mode, introducing SUPPORTED_NODE_RUNTIMES constants, and corresponding unit tests for the new behavior.
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
  • Commit unit tests in branch sc-3833

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.

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.

🧹 Nitpick comments (1)
packages/serverless/test/unit/lib/plugins/aws/dev.test.js (1)

125-145: Test correctly verifies the supported-runtime path, but consider also asserting warning count.

The test validates the runtime is set to nodejs22.x and the mismatch warning fires. For parity with the unsupported-runtime test (which asserts toHaveBeenCalledTimes(1)), consider adding a toHaveBeenCalledTimes(1) assertion here too, to ensure only the mismatch warning fires and no spurious fallback warning is emitted.

Suggested addition
       expect(functionConfig.runtime).toBe('nodejs22.x')
+      expect(mockLogger.warning).toHaveBeenCalledTimes(1)
       expect(mockLogger.warning).toHaveBeenCalledWith(
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/serverless/test/unit/lib/plugins/aws/dev.test.js` around lines 125 -
145, Add an assertion that the mismatch warning was called exactly once to
mirror the unsupported-runtime test: after the existing expects in the describe
'#update()' it block (the one that sets runtime to nodejs22.x and checks
mockLogger.warning was called with the mismatch message), add an assertion using
mockLogger.warning and toHaveBeenCalledTimes(1). Reference the test's
awsDev.update invocation, the functionConfig object, and mockLogger.warning to
place the new expectation.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@packages/serverless/test/unit/lib/plugins/aws/dev.test.js`:
- Around line 125-145: Add an assertion that the mismatch warning was called
exactly once to mirror the unsupported-runtime test: after the existing expects
in the describe '#update()' it block (the one that sets runtime to nodejs22.x
and checks mockLogger.warning was called with the mismatch message), add an
assertion using mockLogger.warning and toHaveBeenCalledTimes(1). Reference the
test's awsDev.update invocation, the functionConfig object, and
mockLogger.warning to place the new expectation.

@czubocha
Copy link
Contributor Author

@cursor review

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

@czubocha czubocha merged commit 1f0abd8 into main Feb 19, 2026
13 checks passed
@czubocha czubocha deleted the sc-3833 branch February 19, 2026 16:09
@github-actions github-actions bot locked and limited conversation to collaborators Feb 19, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

serverless dev fails for durable functions

2 participants