Skip to content

feat(aws-lambda): add AWS Lambda adapter with response streaming - #48

Merged
dinwwwh merged 5 commits into
mainfrom
claude/aws-lambda-adapter-streaming-074fad
Aug 2, 2026
Merged

feat(aws-lambda): add AWS Lambda adapter with response streaming#48
dinwwwh merged 5 commits into
mainfrom
claude/aws-lambda-adapter-streaming-074fad

Conversation

@dinwwwh

@dinwwwh dinwwwh commented Aug 2, 2026

Copy link
Copy Markdown
Member

Adds @standardserver/aws-lambda, an adapter that converts AWS API Gateway proxy events (payload formats 1.0 and 2.0, the latter also used by Lambda Function URLs) into StandardLazyRequest, and writes StandardResponse through the stream awslambda.streamifyResponse provides. Streaming bodies such as server-sent events now reach clients as they are produced instead of being buffered by the function.

Behavior

  • Both payload formats are accepted through one API; format 1.0 is detected by its top-level httpMethod field, and events typed with @types/aws-lambda are accepted directly (verified by type tests).
  • Status, headers, and cookies are sent via the awslambda.HttpResponseStream metadata prelude; multiple set-cookie values survive through the dedicated cookies field.
  • Body resolution matches the fetch and node adapters (same hint → standard-servercontent-typecontent-length priority), so the same request resolves to the same StandardBody on every adapter.
  • Format 2.0 cookies are restored into a cookie header, and format 1.0 query strings are re-encoded; 2.0's rawQueryString passes through untouched.
  • Importing the package never pollutes consumer global types — the awslambda global is described by the exported AwsLambdaGlobal type and declared module-locally inside the adapter.

Also included

  • @standardserver/node: canWriteToNodeResponse and getNodeResponseError now check both the response and its underlying http2 stream instead of trusting only the inner stream (separate commit).

Testing

  • 60 unit tests plus compile-time type tests against @types/aws-lambda (dev-dependency only); package coverage is 100% on statements, branches, functions, and lines.
  • Full repo suite passes (908 tests), including the existing http1/http2 tests exercising the node utils change.

dinwwwh added 2 commits August 2, 2026 11:19
Adds @standardserver/aws-lambda, which converts API Gateway proxy events
(payload format 1.0) into StandardLazyRequest and writes StandardResponse
through the stream provided by awslambda.streamifyResponse, sending status,
headers, and cookies via the awslambda.HttpResponseStream metadata prelude.
…e utils

canWriteToNodeResponse and getNodeResponseError previously trusted only the
inner http2 stream when one exists; now the response's own state is checked
and used as an error fallback too, so wrappers carrying their own writable
state are no longer misjudged.
@pkg-pr-new

pkg-pr-new Bot commented Aug 2, 2026

Copy link
Copy Markdown
@standardserver/aws-lambda

npm i https://pkg.pr.new/@standardserver/aws-lambda@48

@standardserver/bun

npm i https://pkg.pr.new/@standardserver/bun@48

@standardserver/core

npm i https://pkg.pr.new/@standardserver/core@48

@standardserver/deno

npm i https://pkg.pr.new/@standardserver/deno@48

@standardserver/fastify

npm i https://pkg.pr.new/@standardserver/fastify@48

@standardserver/fetch

npm i https://pkg.pr.new/@standardserver/fetch@48

@standardserver/node

npm i https://pkg.pr.new/@standardserver/node@48

@standardserver/peer

npm i https://pkg.pr.new/@standardserver/peer@48

@standardserver/shared

npm i https://pkg.pr.new/@standardserver/shared@48

commit: 703bf7c

@codecov

codecov Bot commented Aug 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@codspeed-hq

codspeed-hq Bot commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 26 untouched benchmarks
⏩ 108 skipped benchmarks1


Comparing claude/aws-lambda-adapter-streaming-074fad (703bf7c) with main (463adc1)2

Open in CodSpeed

Footnotes

  1. 108 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

  2. No successful run was found on main (65d6e59) during the generation of this report, so 463adc1 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds a new AWS Lambda adapter package that maps API Gateway (v1/v2) events into StandardLazyRequest and writes StandardResponse via awslambda.streamifyResponse for true response streaming, plus a small hardening change in the Node adapter response writability/error checks.

Changes:

  • Introduces @standardserver/aws-lambda with event → request conversion, header/url/body normalization, and streamed response writing.
  • Adds comprehensive unit + type-level tests for the new adapter package.
  • Updates Node adapter utilities to validate both the response wrapper and underlying http2 stream.

Reviewed changes

Copilot reviewed 23 out of 24 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
README.md Adds the new @standardserver/aws-lambda package to the project package list.
pnpm-lock.yaml Adds the new workspace package and pins dev deps (@types/aws-lambda, bumps @types/node, etc.).
playgrounds/node-http/package.json Bumps @types/node devDependency version.
playgrounds/hono-node/package.json Bumps @hono/node-server and @types/node devDependency versions.
packages/node/src/utils.ts Updates response writability/error helpers to account for underlying http2 stream state/errors.
packages/node/package.json Bumps @types/node devDependency version.
packages/fastify/package.json Bumps @types/node devDependency version.
packages/aws-lambda/tsconfig.json Adds TS project config for the new aws-lambda package.
packages/aws-lambda/package.json Defines the new package metadata, exports, deps, and build/typecheck scripts.
packages/aws-lambda/README.md Documents adapter behavior, usage, and Lambda-specific caveats.
packages/aws-lambda/src/index.ts Exposes the adapter’s public API surface.
packages/aws-lambda/src/index.test.ts Basic export-surface sanity test.
packages/aws-lambda/src/types.ts Defines structural event/stream/global types without polluting consumer globals.
packages/aws-lambda/src/types.test-d.ts Compile-time compatibility checks vs @types/aws-lambda.
packages/aws-lambda/src/url.ts Implements v1/v2 URL reconstruction (including v1 query re-encoding).
packages/aws-lambda/src/url.test.ts Tests v1/v2 URL reconstruction behavior.
packages/aws-lambda/src/headers.ts Implements v1/v2 header normalization + set-cookie splitting for Lambda metadata.
packages/aws-lambda/src/headers.test.ts Tests header normalization, cookie restoration, and set-cookie handling.
packages/aws-lambda/src/body.ts Implements buffered body decoding + hint/content-type/content-length-based parsing.
packages/aws-lambda/src/body.test.ts Tests body parsing across supported hints and encodings.
packages/aws-lambda/src/request.ts Builds StandardLazyRequest from events and response-stream abort signal.
packages/aws-lambda/src/request.test.ts Tests lazy headers, method/url/body resolution, and abort behavior.
packages/aws-lambda/src/response.ts Streams StandardResponse via Lambda response-stream metadata prelude + body piping.
packages/aws-lambda/src/response.test.ts Tests buffered and streaming responses, cookies/headers metadata, and error/close handling.
Files not reviewed (1)
  • pnpm-lock.yaml: Generated file

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/aws-lambda/src/headers.ts Outdated
}
})

// WARNING: errors that occur here are silently ignored and not reported to the Promise
dinwwwh and others added 2 commits August 2, 2026 12:04
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@dinwwwh
dinwwwh merged commit fada571 into main Aug 2, 2026
10 checks passed
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.

2 participants