@cero-base/cero 1.5.0 → 1.5.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cero-base/cero",
3
- "version": "1.5.0",
3
+ "version": "1.5.1",
4
4
  "description": "The ideal p2p API — everything is a handle, handles contain refs, refs contain rows.",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -95,7 +95,7 @@
95
95
  "test:node": "ls test/*.test.js | xargs -P1 -n1 brittle-node"
96
96
  },
97
97
  "dependencies": {
98
- "@cero-base/core": "^1.5.0",
98
+ "@cero-base/core": "^1.5.1",
99
99
  "b4a": "^1.8.1",
100
100
  "bare-abort-controller": "^1.1.2",
101
101
  "bare-crypto": "^1.15.3",
@@ -118,9 +118,9 @@
118
118
  "devDependencies": {
119
119
  "@hyperswarm/testnet": "^3.1.4",
120
120
  "bare-events": "^2.9.1",
121
- "bare-fetch": "^3.0.3",
122
- "bare-process": "^4.4.1",
123
- "bare-url": "^2.2.1",
121
+ "bare-fetch": "^3.2.0",
122
+ "bare-process": "^4.5.1",
123
+ "bare-url": "^2.4.6",
124
124
  "brittle": "^4.1.0",
125
125
  "typescript": "^5.9.3"
126
126
  },
package/src/rpc/client.js CHANGED
@@ -304,7 +304,9 @@ const operators = {
304
304
  }
305
305
  wire.on('end', end)
306
306
  wire.on('close', end)
307
- wire.on('error', (err) => out.destroy(err))
307
+ // the channel tears the stream down on client close — that is an end,
308
+ // not a failure (bare-rpc ≥1.3.2 errors every in-flight op on teardown)
309
+ wire.on('error', (err) => (err.code === 'CHANNEL_CLOSED' ? end() : out.destroy(err)))
308
310
  return out
309
311
  },
310
312
 
@@ -343,9 +345,9 @@ const operators = {
343
345
  }
344
346
  pump().catch((err) => {
345
347
  if (out.destroyed) return
346
- // the server tears the stream down on handle close that is an end,
347
- // not a failure (same contract as watch)
348
- if (err.code === 'PREMATURE_CLOSE') out.push(null)
348
+ // the server tears the stream down on handle close, and the channel on
349
+ // client close — both are ends, not failures (same contract as watch)
350
+ if (err.code === 'PREMATURE_CLOSE' || err.code === 'CHANNEL_CLOSED') out.push(null)
349
351
  else out.destroy(err)
350
352
  })
351
353
  return out
package/src/rpc/server.js CHANGED
@@ -211,6 +211,9 @@ export class Server extends RPCServer {
211
211
  if (!set) this._watchStreams.set(handle, (set = new Set()))
212
212
  set.add(stream)
213
213
  live.on('data', onData)
214
+ // channel teardown destroys the stream with CHANNEL_CLOSED — 'close'
215
+ // below does the cleanup; the error itself must not crash the server
216
+ stream.on('error', safetyCatch)
214
217
  stream.on('close', () => {
215
218
  live.off('data', onData)
216
219
  live.destroy()
@@ -245,6 +248,7 @@ export class Server extends RPCServer {
245
248
  }
246
249
  }
247
250
  pump().catch(safetyCatch)
251
+ stream.on('error', safetyCatch)
248
252
  stream.on('close', () => {
249
253
  live.destroy()
250
254
  this._watchStreams.get(handle)?.delete(stream)