-
-
Notifications
You must be signed in to change notification settings - Fork 807
Drop pre-NodeJS 20.x support and add support for NodeJS 24.x and Fix broken tests #1867
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
This commit modernizes the codebase to support only Node.js 20+ and fixes test failures caused by Serverless Framework v4's authentication mechanism. ## Summary of Changes ### 1. Removed Node.js 14, 16, and 18 Support (78 files modified) - Update supported runtimes to Node.js 20, 22, and 24 only - Remove nodejs14.x, nodejs16.x, nodejs18.x from supportedRuntimes - Update DEFAULT_LAMBDA_RUNTIME from nodejs14.x to nodejs20.x - Update package.json minimum Node version: >=18.12.0 → >=20.0.0 - Update CI workflow to test only Node.js 20, 22, 24 - Delete nodejs14.x, nodejs16.x, nodejs18.x test directories - Update 71 serverless.yml files to use nodejs20.x runtime ### 2. Fixed Test Authentication for Serverless Framework v4 **Root Cause**: Serverless v4 uses a compiled binary that makes HTTP requests for authentication. Nock mocks cannot intercept requests from external binaries, only from the same Node.js process. **Solution**: Require real SERVERLESS_ACCESS_KEY environment variable - Add pre-test validation in mochaHooks.cjs that exits immediately if key not set - Update setupTeardown.js to use SERVERLESS_ACCESS_KEY from environment - Remove non-functional nock mock setup (serverlessApiMockSetup.cjs) - Add SERVERLESS_ACCESS_KEY to GitHub Actions workflow (requires secret) - Display helpful error message with instructions when key is missing ### 3. Files Changed Core configuration: - src/config/supportedRuntimes.js - src/config/constants.js - package.json - .github/workflows/nodejs.yml Test infrastructure: - tests/mochaHooks.cjs (added validation) - tests/_testHelpers/setupTeardown.js (use real API key) - tests/_testHelpers/serverlessApiMockSetup.cjs (deleted) Configuration files: - 71 serverless.yml files updated across tests/, examples/, and integration tests - 2 markdown issue templates updated ### How to Run Tests Locally: ```bash # Option 1: Login with Serverless npx serverless login # Option 2: Set API key directly export SERVERLESS_ACCESS_KEY=your_key_here # Run tests npm test ``` In CI: Add SERVERLESS_ACCESS_KEY to GitHub repository secrets 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
|
Waiting for this PR to be merged as now I can't use serverless-offline with node.js 24, which is now officially supported by AWS |
|
@dherault Is there anything else need to be done to get this merged? |
|
I tested this branch and it seems to work fine for me, but there are 4 failing checks |
| cwd: servicePath, | ||
| env: { | ||
| SERVERLESS_ACCESS_KEY: "MOCK_ACCESS_KEY", | ||
| SERVERLESS_ACCESS_KEY: serverlessAccessKey, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you need to pass an actual serverless key here instead of using a mock?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Serverless Framework v4 uses a compiled binary (Go) instead of pure JavaScript
The binary makes HTTP requests to https://core.serverless.com/api for authentication
Nock mocks don't work because they can only intercept requests in the same Node.js
process, not external binaries so the mock API key approach was fundamentally broken
Description
Investigated Test Failures
Problem: Tests were failing with "Unauthorized" errors when running npm test
Root Cause Discovered:
process, not external binaries
Solution: Switched to using real Serverless API keys for testing
Removed Node.js 14, 16, and 18 Support 🗑️
AWS only supports NodeJS 20+
Key Changes:
supported runtimes
nodejs20.x
Implemented Real API Key Authentication
Problem: Tests needed a way to authenticate with Serverless Framework v4
Solution Implemented:
A. Added Pre-Test Validation (tests/mochaHooks.cjs)
B. Updated Test Setup (tests/_testHelpers/setupTeardown.js)
C. Updated CI Workflow (.github/workflows/nodejs.yml)
D. Cleaned Up Unused Files
Motivation and Context
How Has This Been Tested?
Screenshots (if appropriate):