Skip to content

Commit 7d6d7f6

Browse files
committed
refactor(@angular/ssr): drain node stream
1 parent 8fb9f96 commit 7d6d7f6

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

packages/angular/ssr/node/src/response.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
import type { ServerResponse } from 'node:http';
1010
import type { Http2ServerResponse } from 'node:http2';
11+
import type { ReadableStreamReadResult } from 'node:stream/web';
1112

1213
/**
1314
* Streams a web-standard `Response` into a Node.js `ServerResponse`
@@ -71,7 +72,10 @@ export async function writeResponseToNodeResponse(
7172
break;
7273
}
7374

74-
(destination as ServerResponse).write(value);
75+
const canContinue = (destination as ServerResponse).write(value);
76+
if (!canContinue) {
77+
await new Promise<void>((resolve) => destination.once('drain', resolve));
78+
}
7579
}
7680
} catch {
7781
destination.end('Internal server error.');

0 commit comments

Comments
 (0)