rocksdb-native 3.5.3 → 3.5.4

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 CHANGED
@@ -81,8 +81,9 @@ class RocksDB {
81
81
  if (this._index !== -1) this._state.removeSession(this)
82
82
 
83
83
  if (force) {
84
- while (this._state.sessions.length > 0)
84
+ while (this._state.sessions.length > 0) {
85
85
  await this._state.sessions[this._state.sessions.length - 1].close()
86
+ }
86
87
  }
87
88
 
88
89
  return this.isRoot() ? this._state.close() : Promise.resolve()
package/lib/iterator.js CHANGED
@@ -101,8 +101,16 @@ module.exports = class RocksDBIterator extends Readable {
101
101
  async _open(cb) {
102
102
  await this.ready()
103
103
 
104
+ this._db._state.io.inc()
105
+
104
106
  if (this._db._state.resumed !== null) {
105
- await this._db._state.resumed.promise
107
+ const resumed = await this._db._state.resumed.promise
108
+
109
+ if (!resumed) {
110
+ this._db._state.io.dec()
111
+
112
+ return cb(new Error('RocksDB session is closed'))
113
+ }
106
114
  }
107
115
 
108
116
  this._pendingOpen = cb
@@ -122,8 +130,6 @@ module.exports = class RocksDBIterator extends Readable {
122
130
  this._onclose,
123
131
  this._onread
124
132
  )
125
-
126
- this._db._state.io.inc()
127
133
  }
128
134
 
129
135
  async _read(cb) {
package/lib/state.js CHANGED
@@ -158,11 +158,7 @@ module.exports = class RocksDBState extends ReadyResource {
158
158
  }
159
159
 
160
160
  async _close() {
161
- if (this.resumed) {
162
- const resumed = this.resumed
163
- this.resumed = null
164
- resumed.resolve(false)
165
- }
161
+ if (this.resumed) this.resumed.resolve(false)
166
162
 
167
163
  while (!this.handles.isIdle()) await this.handles.idle()
168
164
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rocksdb-native",
3
- "version": "3.5.3",
3
+ "version": "3.5.4",
4
4
  "description": "librocksdb bindings for JavaScript",
5
5
  "exports": {
6
6
  ".": "./index.js",