@cero-base/core 1.14.0 → 1.14.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 +7 -7
- package/src/database/index.js +8 -4
- package/src/network/index.js +18 -16
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cero-base/core",
|
|
3
|
-
"version": "1.14.
|
|
3
|
+
"version": "1.14.1",
|
|
4
4
|
"description": "cero p2p primitives — identity, storage, network, database, blobs, rpc, pairing.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -136,17 +136,17 @@
|
|
|
136
136
|
},
|
|
137
137
|
"dependencies": {
|
|
138
138
|
"@hyperswarm/secret-stream": "^6.9.1",
|
|
139
|
-
"autobee": "2.0.0-rc.
|
|
139
|
+
"autobee": "2.0.0-rc.25",
|
|
140
140
|
"autobee-encryption": "0.1.3",
|
|
141
141
|
"b4a": "^1.8.1",
|
|
142
142
|
"bare-crypto": "^1.15.3",
|
|
143
|
-
"bare-fs": "^4.8.
|
|
143
|
+
"bare-fs": "^4.8.1",
|
|
144
144
|
"bare-path": "^3.1.1",
|
|
145
145
|
"bip39-mnemonic": "^2.5.0",
|
|
146
146
|
"blind-pairing": "^2.3.1",
|
|
147
147
|
"blind-peering": "^2.6.3",
|
|
148
148
|
"compact-encoding": "^3.3.2",
|
|
149
|
-
"corestore": "^7.12.
|
|
149
|
+
"corestore": "^7.12.2",
|
|
150
150
|
"framed-stream": "^1.0.1",
|
|
151
151
|
"hrpc": "^4.3.1",
|
|
152
152
|
"hyperblobs": "^2.12.1",
|
|
@@ -164,17 +164,17 @@
|
|
|
164
164
|
"ready-resource": "^1.2.0",
|
|
165
165
|
"safety-catch": "^1.0.3",
|
|
166
166
|
"sodium-universal": "^5.0.1",
|
|
167
|
-
"streamx": "^2.28.
|
|
167
|
+
"streamx": "^2.28.1",
|
|
168
168
|
"z32": "^1.1.0"
|
|
169
169
|
},
|
|
170
170
|
"devDependencies": {
|
|
171
171
|
"@hyperswarm/testnet": "^3.1.4",
|
|
172
172
|
"bare-abort-controller": "^1.1.2",
|
|
173
|
-
"bare-events": "^2.9.
|
|
173
|
+
"bare-events": "^2.9.2",
|
|
174
174
|
"bare-fetch": "^3.2.0",
|
|
175
175
|
"bare-process": "^4.5.1",
|
|
176
176
|
"bare-url": "^2.5.2",
|
|
177
|
-
"blind-peer": "^3.
|
|
177
|
+
"blind-peer": "^3.14.0",
|
|
178
178
|
"brittle": "^4.1.0",
|
|
179
179
|
"typescript": "^5.9.3",
|
|
180
180
|
"which-runtime": "^1.4.0"
|
package/src/database/index.js
CHANGED
|
@@ -129,7 +129,9 @@ export class Database extends ReadyResource {
|
|
|
129
129
|
this._healTimer = null
|
|
130
130
|
}
|
|
131
131
|
if (this._discovery) {
|
|
132
|
-
|
|
132
|
+
// unannounce in the background — awaiting the DHT round-trip here
|
|
133
|
+
// blocks every close (and the writer-swap reboot) for seconds
|
|
134
|
+
this._discovery.destroy().catch(safetyCatch)
|
|
133
135
|
this._discovery = null
|
|
134
136
|
}
|
|
135
137
|
if (this.bee) {
|
|
@@ -252,12 +254,14 @@ export class Database extends ReadyResource {
|
|
|
252
254
|
|
|
253
255
|
if (this.network) {
|
|
254
256
|
this.network.attach(bee)
|
|
255
|
-
// a writer swap re-opens the bee
|
|
256
|
-
//
|
|
257
|
-
|
|
257
|
+
// a writer swap re-opens the bee on the SAME topic — join first so the
|
|
258
|
+
// old session's destroy is a refcounted detach, not a DHT unannounce
|
|
259
|
+
// round-trip (which blocked the swap for seconds)
|
|
260
|
+
const prev = this._discovery
|
|
258
261
|
this._discovery = this.network.join(bee.discoveryKey, {
|
|
259
262
|
mode: this.passive ? PASSIVE : ACTIVE
|
|
260
263
|
})
|
|
264
|
+
if (prev) await prev.destroy()
|
|
261
265
|
}
|
|
262
266
|
}
|
|
263
267
|
|
package/src/network/index.js
CHANGED
|
@@ -240,12 +240,24 @@ export class Network extends ReadyResource {
|
|
|
240
240
|
}
|
|
241
241
|
this._injected.clear()
|
|
242
242
|
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
243
|
+
// stop every discovery session NOW (timers die synchronously) but never
|
|
244
|
+
// await the DHT unannounce round-trips — the force destroy below skips
|
|
245
|
+
// upstream's own clear(), so un-destroyed sessions would leak live timers
|
|
246
|
+
for (const d of [...this._discoveries]) d.destroy().catch(safetyCatch)
|
|
247
|
+
this._discoveries.clear()
|
|
248
|
+
|
|
249
|
+
// the swarm dies FIRST, with force: every polite per-topic DHT unannounce
|
|
250
|
+
// (blind-pairing's included) becomes an instant no-op instead of a network
|
|
251
|
+
// round-trip — a vanished node ages out of the DHT regardless
|
|
252
|
+
const swarm = this._swarm
|
|
253
|
+
this._swarm = null
|
|
254
|
+
if (swarm) {
|
|
255
|
+
// even force destroy awaits a graceful server.close DHT round-trip
|
|
256
|
+
// upstream — cap the wait and let the teardown finish in the background
|
|
257
|
+
await Promise.race([
|
|
258
|
+
swarm.destroy({ force: true }).catch(safetyCatch),
|
|
259
|
+
new Promise((r) => setTimeout(r, 750))
|
|
260
|
+
])
|
|
249
261
|
}
|
|
250
262
|
|
|
251
263
|
if (this._blindPeering) {
|
|
@@ -266,16 +278,6 @@ export class Network extends ReadyResource {
|
|
|
266
278
|
this._blind = null
|
|
267
279
|
}
|
|
268
280
|
|
|
269
|
-
if (this._swarm) {
|
|
270
|
-
try {
|
|
271
|
-
await this.flush()
|
|
272
|
-
await this._swarm.destroy()
|
|
273
|
-
} catch (err) {
|
|
274
|
-
safetyCatch(err)
|
|
275
|
-
}
|
|
276
|
-
this._swarm = null
|
|
277
|
-
}
|
|
278
|
-
|
|
279
281
|
if (this.wakeup) {
|
|
280
282
|
try {
|
|
281
283
|
await this.wakeup.destroy()
|