@cero-base/cero 3.0.0 → 3.0.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": "3.0.0",
3
+ "version": "3.0.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,
@@ -113,7 +113,7 @@
113
113
  "test:node": "find test -name '*.test.js' | sort | xargs -P4 -n1 brittle-node"
114
114
  },
115
115
  "dependencies": {
116
- "@cero-base/core": "^3.0.0",
116
+ "@cero-base/core": "^3.0.1",
117
117
  "b4a": "^1.9.0",
118
118
  "bare-abort-controller": "^1.1.2",
119
119
  "bare-crypto": "^1.15.4",
@@ -1191,7 +1191,8 @@ export class Handle extends ReadyResource {
1191
1191
  join.done.catch(safetyCatch)
1192
1192
  this._joining.set(id, join)
1193
1193
  }
1194
- if (join.invite !== invite) this._run(join, invite)
1194
+ // a join past its reply enters with those keys: a newer invite waits on it
1195
+ if (join.invite !== invite && !join.entering) this._run(join, invite)
1195
1196
  return join
1196
1197
  }
1197
1198
 
@@ -1220,6 +1221,9 @@ export class Handle extends ReadyResource {
1220
1221
  const reply = row.encryptionKey
1221
1222
  ? { ...row, epochs: row.epochs ? c.decode(epochEntries, row.epochs) : [], writer }
1222
1223
  : await Pairing.join(mailbox, invite, opts)
1224
+ // an abort stops no reply already in hand: the newer attempt enters
1225
+ if (running !== join.running) return
1226
+ join.entering = true
1223
1227
  await this._stand(id, 'joining', keys(reply))
1224
1228
  const child = await this._enter(join.type, reply, invite)
1225
1229
  // every waiter takes its own hold once the row reads in: this one is let go, idle until the app opens it
@@ -1664,7 +1668,7 @@ export class Handle extends ReadyResource {
1664
1668
  const onchange = (touched) => {
1665
1669
  if (touched.has('*') || touched.has('devices') || touched.has('members')) {
1666
1670
  this._index(child).catch(this._onerror)
1667
- this._ousted(child).catch(this._onerror)
1671
+ this._ousted(child).catch((err) => this.closing || this._onerror(err))
1668
1672
  }
1669
1673
  }
1670
1674
  child.store.on('update', onchange)