fix: Node.js 24 compatibility — replace callback handlers with async return#111
Merged
Conversation
… compatibility AWS Lambda Node.js 24 runtime removed support for callback-based function handlers (Runtime.CallbackHandlerDeprecated). Both s3-handler and ag-handler were async functions still using the deprecated callback(null, response) pattern. Converted to return the response object directly. Updated all unit tests accordingly; also fixed a pre-existing silent test bug where the "directory" fixture key had no trailing slash and assertions inside callbacks were silently swallowed by mocha. Fixes #110
Two complementary checks to prevent #110 from recurring: 1. Unit-test arity assertion. Each handler test asserts `handler.length <= 2`, which is what AWS Lambda's runtime client checks (`errorOnDeprecatedCallback`) before deciding whether to reject async-with-callback handlers. Cheap, runs on every Node version in the existing matrix. 2. Runtime init smoke job. New CI job spins up each handler inside the official `public.ecr.aws/lambda/nodejs:24` image (with the Runtime Interface Emulator bundled) and POSTs an invocation. The handler's own assertions on the empty event are expected to fail — we only fail CI if the response contains a `Runtime.*` errorType (CallbackHandlerDeprecated, ImportModuleError, MalformedHandlerName, etc.), which means init itself broke. Verified locally against a synthetic callback-shaped handler: detected.
scanii-lambda only ever runs on the Linux Lambda runtime — testing on windows and macos was burning runner minutes for no signal.
2 tasks
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.
Summary
lib/s3-handler.jsandlib/ag-handler.jswereasyncfunctions that still calledcallback(null, response)— the pattern AWS Lambda Node.js 24 removed (Runtime.CallbackHandlerDeprecated)async (event, context) => { return response }— the only supported pattern in Node.js 24+const result = await handler(event, {})and assert on the returned value/so the directory check never triggered; assertions inside the old callback were silently swallowed by mocha, masking the broken testRegression guards (so this doesn't happen again)
handler.length <= 2, matching what AWS's runtime client checks. Cheap, runs on every Node version in the existing matrix.public.ecr.aws/lambda/nodejs:24(Runtime Interface Emulator bundled) and POSTs an invocation. We only fail onRuntime.*errorType in the response (CallbackHandlerDeprecated,ImportModuleError,MalformedHandlerName, …) — handler-side errors from the empty event are expected. Verified locally against a synthetic callback-shaped handler: detected.Test plan
npm test— passing locally (34 unit tests + 4 integration pending without local scanii-cli)setup-cli-actionLambda Node 24 runtime init smokejob exercises real runtime initFixes #110