braid-http 1.3.88 → 1.3.90
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/braid-http-server.js +13 -6
- package/package.json +1 -1
package/braid-http-server.js
CHANGED
|
@@ -229,6 +229,9 @@ function braidify (req, res, next) {
|
|
|
229
229
|
|
|
230
230
|
// console.log('\n## Braidifying', req.method, req.url, req.headers.peer)
|
|
231
231
|
|
|
232
|
+
// Prevent uncaught EPIPE crashes on client disconnect
|
|
233
|
+
res.on('error', (_e) => {})
|
|
234
|
+
|
|
232
235
|
// First, declare that we support Patches and JSON ranges.
|
|
233
236
|
res.setHeader('Range-Request-Allow-Methods', 'PATCH, PUT')
|
|
234
237
|
res.setHeader('Range-Request-Allow-Units', 'json')
|
|
@@ -283,12 +286,15 @@ function braidify (req, res, next) {
|
|
|
283
286
|
|
|
284
287
|
braidify.multiplexers.set(multiplexer, {requests: new Map(), res})
|
|
285
288
|
|
|
286
|
-
//
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
289
|
+
// Clean up multiplexer on error or close
|
|
290
|
+
function cleanup() {
|
|
291
|
+
var m = braidify.multiplexers.get(multiplexer)
|
|
292
|
+
if (!m) return
|
|
293
|
+
for (var f of m.requests.values()) f()
|
|
290
294
|
braidify.multiplexers.delete(multiplexer)
|
|
291
|
-
}
|
|
295
|
+
}
|
|
296
|
+
res.on('error', cleanup)
|
|
297
|
+
res.on('close', cleanup)
|
|
292
298
|
|
|
293
299
|
// keep the connection open,
|
|
294
300
|
// so people can send multiplexed data to it
|
|
@@ -462,8 +468,9 @@ function braidify (req, res, next) {
|
|
|
462
468
|
key === '_events' || key === 'emit'
|
|
463
469
|
|
|
464
470
|
// empirically, on an http1 server,
|
|
465
|
-
//
|
|
471
|
+
// these cause res2 to close prematurely
|
|
466
472
|
|| key === 'destroyed'
|
|
473
|
+
|| key === '_closed'
|
|
467
474
|
|
|
468
475
|
// adding these lines gets rid of some deprecation warnings.. keep?
|
|
469
476
|
|| key === '_headers'
|