Skip to content

presets(aws-lambda): switch to srvx#4056

Open
RihanArfan wants to merge 1 commit intomainfrom
refactor/aws-lambda-srvx
Open

presets(aws-lambda): switch to srvx#4056
RihanArfan wants to merge 1 commit intomainfrom
refactor/aws-lambda-srvx

Conversation

@RihanArfan
Copy link
Member

❓ Type of change

  • 📖 Documentation (updates to the documentation, readme, or JSdoc annotations)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • 👌 Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

📚 Description

Refactors the Nitro preset to use srvx's AWS lambda compatibility adapter handler.

📝 Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@RihanArfan RihanArfan requested a review from pi0 as a code owner February 24, 2026 16:07
@vercel
Copy link

vercel bot commented Feb 24, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
nitro.build Ready Ready Preview, Comment Feb 24, 2026 4:08pm

Request Review

@coderabbitai
Copy link

coderabbitai bot commented Feb 24, 2026

📝 Walkthrough

Walkthrough

The PR removes a standalone AWS Lambda utility module and consolidates its functionality by refactoring Lambda handlers to use extracted functions from srvx/aws-lambda, while updating the Stormkit preset to use a new encoding helper. This involves deleting utilities and simplifying handler implementations.

Changes

Cohort / File(s) Summary
Lambda utilities removal
src/presets/aws-lambda/runtime/_utils.ts
Entire file deleted containing utilities for converting AWS Lambda proxy events to/from standard web requests and responses, including awsRequest, awsResponseHeaders, awsResponseBody, and helper functions isTextType and toBuffer.
Lambda handler consolidation
src/presets/aws-lambda/runtime/aws-lambda.ts, src/presets/aws-lambda/runtime/aws-lambda-streaming.ts
Handler implementations refactored to delegate to external functions (handleLambdaEvent and handleLambdaEventWithStream from srvx/aws-lambda). Imports updated from explicit AWS proxy types to unified AwsLambdaEvent type, and manual event/response construction logic removed.
Stormkit preset update
src/presets/stormkit/runtime/stormkit.ts
awsResponseBody usage replaced with new encodeResponseBody helper; internal helpers isTextType and toBuffer added for streaming-to-buffer conversion and conditional base64 encoding.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title follows conventional commits format with the 'presets' scope and 'aws-lambda' subject, clearly describing the main refactoring to use srvx.
Description check ✅ Passed The description explains the refactoring purpose and relates directly to the changeset, which moves AWS Lambda handling logic to use srvx's adapter.

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

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch refactor/aws-lambda-srvx

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

@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)
src/presets/stormkit/runtime/stormkit.ts (1)

56-91: Prefer Response.arrayBuffer() over manual stream plumbing.

You can simplify encodeResponseBody and drop toBuffer, reducing reliance on WritableStream.pipeTo while keeping behavior identical.

♻️ Proposed simplification
 async function encodeResponseBody(
   response: Response
 ): Promise<{ body: string; isBase64Encoded?: boolean }> {
   if (!response.body) {
     return { body: "" };
   }
-  const buffer = await toBuffer(response.body as any);
+  const buffer = Buffer.from(await response.arrayBuffer());
   const contentType = response.headers.get("content-type") || "";
   return isTextType(contentType)
     ? { body: buffer.toString("utf8") }
     : { body: buffer.toString("base64"), isBase64Encoded: true };
 }
@@
-function toBuffer(data: ReadableStream): Promise<Buffer> {
-  return new Promise<Buffer>((resolve, reject) => {
-    const chunks: Buffer[] = [];
-    data
-      .pipeTo(
-        new WritableStream({
-          write(chunk) {
-            chunks.push(chunk);
-          },
-          close() {
-            resolve(Buffer.concat(chunks));
-          },
-          abort(reason) {
-            reject(reason);
-          },
-        })
-      )
-      .catch(reject);
-  });
-}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/presets/stormkit/runtime/stormkit.ts` around lines 56 - 91, Replace the
manual stream plumbing in encodeResponseBody by calling Response.arrayBuffer()
instead of toBuffer: if response.body is empty return {body:""} as before,
otherwise await response.arrayBuffer(), create a Node Buffer via
Buffer.from(arrayBuffer) and use isTextType(contentType) to decide between utf8
string or base64 with isBase64Encoded: true; remove the toBuffer helper entirely
and keep the existing isTextType function and header lookup logic to preserve
behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/presets/stormkit/runtime/stormkit.ts`:
- Around line 56-91: Replace the manual stream plumbing in encodeResponseBody by
calling Response.arrayBuffer() instead of toBuffer: if response.body is empty
return {body:""} as before, otherwise await response.arrayBuffer(), create a
Node Buffer via Buffer.from(arrayBuffer) and use isTextType(contentType) to
decide between utf8 string or base64 with isBase64Encoded: true; remove the
toBuffer helper entirely and keep the existing isTextType function and header
lookup logic to preserve behavior.

ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c0b4642 and 77cc48b.

📒 Files selected for processing (4)
  • src/presets/aws-lambda/runtime/_utils.ts
  • src/presets/aws-lambda/runtime/aws-lambda-streaming.ts
  • src/presets/aws-lambda/runtime/aws-lambda.ts
  • src/presets/stormkit/runtime/stormkit.ts
💤 Files with no reviewable changes (1)
  • src/presets/aws-lambda/runtime/_utils.ts

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.

1 participant