fix(@angular/ssr): prevent stream draining if write does not return a boolean

Implements a workaround for https://github.com/CodeGenieApp/serverless-express/issues/683

Closes #29801
This commit is contained in:
Alan Agius 2025-03-11 12:01:39 +00:00
parent 2d03d8f113
commit ee8466de52

View File

@ -76,7 +76,9 @@ export async function writeResponseToNodeResponse(
} }
const canContinue = (destination as ServerResponse).write(value); const canContinue = (destination as ServerResponse).write(value);
if (!canContinue) { if (canContinue === false) {
// Explicitly check for `false`, as AWS may return `undefined` even though this is not valid.
// See: https://github.com/CodeGenieApp/serverless-express/issues/683
await new Promise<void>((resolve) => destination.once('drain', resolve)); await new Promise<void>((resolve) => destination.once('drain', resolve));
} }
} }