hypercore 11.0.16 → 11.0.17

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.
Files changed (2) hide show
  1. package/index.js +9 -2
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -288,7 +288,6 @@ class Hypercore extends EventEmitter {
288
288
  try {
289
289
  await this._openSession(opts)
290
290
  } catch (err) {
291
- if (this.closing) return
292
291
  if (this.core.autoClose && this.core.hasSession() === false) await this.core.close()
293
292
 
294
293
  if (this.exclusive) this.core.unlockExclusive()
@@ -298,6 +297,7 @@ class Hypercore extends EventEmitter {
298
297
 
299
298
  if (this.state !== null) this.state.removeSession(this)
300
299
 
300
+ this.closed = true
301
301
  this.emit('close', this.core.hasSession() === false)
302
302
  throw err
303
303
  }
@@ -428,7 +428,14 @@ class Hypercore extends EventEmitter {
428
428
  }
429
429
 
430
430
  async _close (error) {
431
- if (this.opened === false) await this.opening
431
+ if (this.opened === false) {
432
+ try {
433
+ await this.opening
434
+ } catch (err) {
435
+ if (!this.closed) throw err
436
+ }
437
+ }
438
+
432
439
  if (this.closed === true) return
433
440
 
434
441
  this.core.removeMonitor(this)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hypercore",
3
- "version": "11.0.16",
3
+ "version": "11.0.17",
4
4
  "description": "Hypercore is a secure, distributed append-only log",
5
5
  "main": "index.js",
6
6
  "scripts": {