@jsenv/server
Advanced tools
Comparing version 12.5.7 to 12.5.8
{ | ||
"name": "@jsenv/server", | ||
"version": "12.5.7", | ||
"version": "12.5.8", | ||
"description": "Write your Node.js server using pure functions", | ||
@@ -19,3 +19,4 @@ "license": "MIT", | ||
"publishConfig": { | ||
"access": "public" | ||
"access": "public", | ||
"registry": "https://registry.npmjs.org" | ||
}, | ||
@@ -71,2 +72,2 @@ "type": "module", | ||
} | ||
} | ||
} |
@@ -47,2 +47,30 @@ import http from "node:http" | ||
await new Promise((resolve) => { | ||
const observable = bodyMethods.asObservable() | ||
const subscription = observable.subscribe({ | ||
next: (data) => { | ||
try { | ||
responseStream.write(data) | ||
} catch (e) { | ||
// Something inside Node.js sometimes puts stream | ||
// in a state where .write() throw despites nodeResponse.destroyed | ||
// being undefined and "close" event not being emitted. | ||
// I have tested if we are the one calling destroy | ||
// (I have commented every .destroy() call) | ||
// but issue still occurs | ||
// For the record it's "hard" to reproduce but can be by running | ||
// a lot of tests against a browser in the context of @jsenv/core testing | ||
if (e.code === "ERR_HTTP2_INVALID_STREAM") { | ||
return | ||
} | ||
responseStream.emit("error", e) | ||
} | ||
}, | ||
error: (value) => { | ||
responseStream.emit("error", value) | ||
}, | ||
complete: () => { | ||
responseStream.end() | ||
}, | ||
}) | ||
raceCallbacks( | ||
@@ -108,30 +136,2 @@ { | ||
) | ||
const observable = bodyMethods.asObservable() | ||
const subscription = observable.subscribe({ | ||
next: (data) => { | ||
try { | ||
responseStream.write(data) | ||
} catch (e) { | ||
// Something inside Node.js sometimes puts stream | ||
// in a state where .write() throw despites nodeResponse.destroyed | ||
// being undefined and "close" event not being emitted. | ||
// I have tested if we are the one calling destroy | ||
// (I have commented every .destroy() call) | ||
// but issue still occurs | ||
// For the record it's "hard" to reproduce but can be by running | ||
// a lot of tests against a browser in the context of @jsenv/core testing | ||
if (e.code === "ERR_HTTP2_INVALID_STREAM") { | ||
return | ||
} | ||
responseStream.emit("error", e) | ||
} | ||
}, | ||
error: (value) => { | ||
responseStream.emit("error", value) | ||
}, | ||
complete: () => { | ||
responseStream.end() | ||
}, | ||
}) | ||
}) | ||
@@ -138,0 +138,0 @@ } |
135167