Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions src/adapters/node/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,11 +196,19 @@ export async function setResponse(res: ServerResponse, response: Response) {

if (done) break;

if (!res.write(value)) {
res.once("drain", next);
return;
const writeResult = res.write(value);
if (!writeResult) {
// In AWS Lambda/serverless environments, drain events may not work properly
// Check if we're in a Lambda-like environment and handle differently
if (process.env.AWS_LAMBDA_FUNCTION_NAME || process.env.LAMBDA_TASK_ROOT) {
// In Lambda, continue without waiting for drain
continue;
} else {
// Standard Node.js behavior
res.once("drain", next);
return;
}
}
}
res.end();
} catch (error) {
cancel(error instanceof Error ? error : new Error(String(error)));
Expand Down