braid-http 1.3.87 → 1.3.89

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.
@@ -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
- // when the response closes,
287
- // let everyone know the multiplexer has died
288
- res.on('close', () => {
289
- for (var f of braidify.multiplexers.get(multiplexer).requests.values()) f()
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
@@ -519,6 +525,7 @@ function braidify (req, res, next) {
519
525
 
520
526
  // We have a subscription!
521
527
  res.statusCode = 209
528
+ res.statusMessage = 'Multiresponse'
522
529
  res.setHeader("subscribe", req.headers.subscribe ?? 'true')
523
530
  res.setHeader('cache-control', 'no-cache, no-transform, no-store')
524
531
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "braid-http",
3
- "version": "1.3.87",
3
+ "version": "1.3.89",
4
4
  "description": "An implementation of Braid-HTTP for Node.js and Browsers",
5
5
  "scripts": {
6
6
  "test": "node test/server.js"