bare-rpc 1.3.0 → 1.3.2

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/index.js CHANGED
@@ -256,7 +256,7 @@ module.exports = exports = class RPC {
256
256
 
257
257
  stream = request._requestStream
258
258
 
259
- if (stream._pendingOpen === null) {
259
+ if (stream === null || stream._pendingOpen === null) {
260
260
  this._pendingRequests.add(message.id)
261
261
  return
262
262
  }
@@ -269,7 +269,7 @@ module.exports = exports = class RPC {
269
269
 
270
270
  stream = request._responseStream
271
271
 
272
- if (stream._pendingOpen === null) {
272
+ if (stream === null || stream._pendingOpen === null) {
273
273
  this._pendingResponses.add(message.id)
274
274
  return
275
275
  }
@@ -297,6 +297,7 @@ module.exports = exports = class RPC {
297
297
  return
298
298
  }
299
299
 
300
+ if (stream === null) return
300
301
  if (message.error) stream.destroy(message.error)
301
302
  else stream.push(null)
302
303
  }
@@ -318,6 +319,7 @@ module.exports = exports = class RPC {
318
319
  return
319
320
  }
320
321
 
322
+ if (stream === null) return
321
323
  stream.cork()
322
324
  }
323
325
 
@@ -338,6 +340,7 @@ module.exports = exports = class RPC {
338
340
  return
339
341
  }
340
342
 
343
+ if (stream === null) return
341
344
  stream.uncork()
342
345
  }
343
346
 
@@ -358,6 +361,7 @@ module.exports = exports = class RPC {
358
361
  return
359
362
  }
360
363
 
364
+ if (stream === null) return
361
365
  if (stream.push(message.data) === false) {
362
366
  this._sendMessage({
363
367
  type: t.STREAM,
@@ -386,6 +390,7 @@ module.exports = exports = class RPC {
386
390
  return
387
391
  }
388
392
 
393
+ if (stream === null) return
389
394
  stream.push(null)
390
395
  }
391
396
 
@@ -406,6 +411,7 @@ module.exports = exports = class RPC {
406
411
  return
407
412
  }
408
413
 
414
+ if (stream === null) return
409
415
  stream.destroy(message.error)
410
416
  }
411
417
 
package/lib/messages.js CHANGED
@@ -114,7 +114,7 @@ exports.message = {
114
114
  case t.REQUEST: {
115
115
  const command = c.uint.decode(state)
116
116
  const stream = c.uint.decode(state)
117
- const data = stream === 0 ? c.buffer.decode(state) : null
117
+ const data = stream === 0 ? c.optionalBuffer.decode(state) : null
118
118
 
119
119
  return { type, id, command, stream, data }
120
120
  }
@@ -128,7 +128,7 @@ exports.message = {
128
128
  }
129
129
 
130
130
  if (stream === 0) {
131
- return { type, id, stream, error: null, data: c.buffer.decode(state) }
131
+ return { type, id, stream, error: null, data: c.optionalBuffer.decode(state) }
132
132
  }
133
133
 
134
134
  return { type, id, stream, error: null, data: null }
@@ -142,7 +142,7 @@ exports.message = {
142
142
  }
143
143
 
144
144
  if (stream & s.DATA) {
145
- return { type, id, stream, error: null, data: c.buffer.decode(state) }
145
+ return { type, id, stream, error: null, data: c.optionalBuffer.decode(state) }
146
146
  }
147
147
 
148
148
  return { type, id, stream, error: null, data: null }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bare-rpc",
3
- "version": "1.3.0",
3
+ "version": "1.3.2",
4
4
  "description": "librpc ABI compatible RPC for Bare",
5
5
  "exports": {
6
6
  ".": {
@@ -38,7 +38,7 @@
38
38
  "dependencies": {
39
39
  "b4a": "^1.6.6",
40
40
  "bare-stream": "^2.1.3",
41
- "compact-encoding": "^2.15.0",
41
+ "compact-encoding": "^3.0.0",
42
42
  "safety-catch": "^1.0.2"
43
43
  },
44
44
  "devDependencies": {