server: ensure sendStream terminates on connection close

This commit is contained in:
Koushik Dutta
2025-04-10 10:47:48 -07:00
parent 5698551b7e
commit c620a4e126

View File

@@ -97,7 +97,12 @@ export class HttpResponseImpl implements HttpResponse {
stream = await clusterSetup.connectRPCObject(stream);
for await (const chunk of stream) {
this.res.write(chunk);
await new Promise<void>((r, f) => this.res.write(chunk, e => {
if (e)
f(e);
else
r();
}));
}
this.res.end();
}