braid-http 0.3.4 → 0.3.5

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.
@@ -324,25 +324,24 @@ async function handle_fetch_stream (stream, cb) {
324
324
  while (true) {
325
325
  var versions = []
326
326
 
327
+ // Read the next chunk of stream!
327
328
  try {
328
- // Read the next chunk of stream!
329
329
  var {done, value} = await reader.read()
330
-
331
- // Check if this connection has been closed!
332
- if (done) {
333
- console.debug("Connection closed.")
334
- cb(null, 'Connection closed')
335
- return
336
- }
337
-
338
- // Tell the parser to process some more stream
339
- parser.read(decoder.decode(value))
340
330
  }
341
-
342
331
  catch (e) {
343
332
  cb(null, e)
344
333
  return
345
334
  }
335
+
336
+ // Check if this connection has been closed!
337
+ if (done) {
338
+ console.debug("Connection closed.")
339
+ cb(null, 'Connection closed')
340
+ return
341
+ }
342
+
343
+ // Tell the parser to process some more stream
344
+ parser.read(decoder.decode(value))
346
345
  }
347
346
  }
348
347
 
@@ -368,9 +367,16 @@ var subscription_parser = (cb) => ({
368
367
 
369
368
  // Now loop through the input and parse until we hit a dead end
370
369
  while (this.state.input.trim() !== '') {
371
- this.state = parse_update (this.state)
372
370
 
373
- // Maybe we parsed a version! That's cool!
371
+ // Try to parse an update
372
+ try {
373
+ this.state = parse_update (this.state)
374
+ } catch (e) {
375
+ this.cb(null, e)
376
+ return
377
+ }
378
+
379
+ // Maybe we parsed an update! That's cool!
374
380
  if (this.state.result === 'success') {
375
381
  this.cb({
376
382
  version: this.state.version,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "braid-http",
3
- "version": "0.3.4",
3
+ "version": "0.3.5",
4
4
  "description": "An implementation of Braid-HTTP for Node.js and Browsers",
5
5
  "scripts": {
6
6
  "test": "node test/server.js"