autobee 2.2.0 → 2.2.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/index.js +25 -1
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -344,6 +344,29 @@ module.exports = class Autobee extends ReadyResource {
|
|
|
344
344
|
async _close() {
|
|
345
345
|
this._interrupting = true
|
|
346
346
|
|
|
347
|
+
// the local core holds the exclusive lock but the local writer closes it
|
|
348
|
+
// early in the teardown, so hand the lock to a detached session that
|
|
349
|
+
// outlives the teardown and only release it once everything is down
|
|
350
|
+
let lock = null
|
|
351
|
+
|
|
352
|
+
if (this.local.exclusive) {
|
|
353
|
+
lock = this.store.session()
|
|
354
|
+
const local = lock.get({ key: this.local.key, active: false })
|
|
355
|
+
await local.ready()
|
|
356
|
+
|
|
357
|
+
// transfer exclusiveness, the detached session now unlocks on close
|
|
358
|
+
local.exclusive = true
|
|
359
|
+
this.local.exclusive = false
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
try {
|
|
363
|
+
await this._teardown()
|
|
364
|
+
} finally {
|
|
365
|
+
if (lock) await lock.close()
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
async _teardown() {
|
|
347
370
|
try {
|
|
348
371
|
await ApplyView.close(this.view, this)
|
|
349
372
|
} catch (err) {
|
|
@@ -351,7 +374,6 @@ module.exports = class Autobee extends ReadyResource {
|
|
|
351
374
|
}
|
|
352
375
|
|
|
353
376
|
if (this.writers) await this.writers.close()
|
|
354
|
-
await this.local.close()
|
|
355
377
|
await this.system.close()
|
|
356
378
|
await this._wakeup.close()
|
|
357
379
|
if (this.bootstrap) await this.bootstrap.close()
|
|
@@ -366,6 +388,8 @@ module.exports = class Autobee extends ReadyResource {
|
|
|
366
388
|
// don't rely on the store teardown to stop the notify watcher
|
|
367
389
|
if (this._notifyHandler) this._notifyHandler.destroy()
|
|
368
390
|
|
|
391
|
+
await this.local.close()
|
|
392
|
+
|
|
369
393
|
// rugpull the rest
|
|
370
394
|
await this.store.close()
|
|
371
395
|
|