@whatwg-node/server
Advanced tools
Comparing version 0.9.44 to 0.9.45-rc-20240726141659-db760872102e9eaeee7ae466944a23ed5192955a
@@ -266,7 +266,22 @@ "use strict"; | ||
async function sendAsyncIterable(serverResponse, asyncIterable) { | ||
let closed = false; | ||
const closeEventListener = () => { | ||
closed = true; | ||
}; | ||
serverResponse.once('error', closeEventListener); | ||
serverResponse.once('close', closeEventListener); | ||
serverResponse.once('finish', () => { | ||
serverResponse.removeListener('close', closeEventListener); | ||
}); | ||
for await (const chunk of asyncIterable) { | ||
if (closed) { | ||
break; | ||
} | ||
if (!serverResponse | ||
// @ts-expect-error http and http2 writes are actually compatible | ||
.write(chunk)) { | ||
break; | ||
if (closed) { | ||
break; | ||
} | ||
await new Promise(resolve => serverResponse.once('drain', resolve)); | ||
} | ||
@@ -273,0 +288,0 @@ } |
@@ -244,7 +244,22 @@ import { URL } from '@whatwg-node/fetch'; | ||
async function sendAsyncIterable(serverResponse, asyncIterable) { | ||
let closed = false; | ||
const closeEventListener = () => { | ||
closed = true; | ||
}; | ||
serverResponse.once('error', closeEventListener); | ||
serverResponse.once('close', closeEventListener); | ||
serverResponse.once('finish', () => { | ||
serverResponse.removeListener('close', closeEventListener); | ||
}); | ||
for await (const chunk of asyncIterable) { | ||
if (closed) { | ||
break; | ||
} | ||
if (!serverResponse | ||
// @ts-expect-error http and http2 writes are actually compatible | ||
.write(chunk)) { | ||
break; | ||
if (closed) { | ||
break; | ||
} | ||
await new Promise(resolve => serverResponse.once('drain', resolve)); | ||
} | ||
@@ -251,0 +266,0 @@ } |
{ | ||
"name": "@whatwg-node/server", | ||
"version": "0.9.44", | ||
"version": "0.9.45-rc-20240726141659-db760872102e9eaeee7ae466944a23ed5192955a", | ||
"description": "Fetch API compliant HTTP Server adapter", | ||
@@ -5,0 +5,0 @@ "sideEffects": false, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
140554
2872