corestore 6.0.1-alpha.17 → 6.0.1-alpha.18
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 +3 -3
- package/package.json +1 -1
- package/test/all.js +14 -0
package/index.js
CHANGED
|
@@ -153,10 +153,10 @@ module.exports = class Corestore extends EventEmitter {
|
|
|
153
153
|
while (this.cores.has(id)) {
|
|
154
154
|
const existing = this.cores.get(id)
|
|
155
155
|
if (existing.opened && !existing.closing) return { from: existing, keyPair, auth }
|
|
156
|
-
if (
|
|
157
|
-
await existing.ready().catch(safetyCatch)
|
|
158
|
-
} else if (existing.closing) {
|
|
156
|
+
if (existing.closing) {
|
|
159
157
|
await existing.close()
|
|
158
|
+
} else {
|
|
159
|
+
await existing.ready().catch(safetyCatch)
|
|
160
160
|
}
|
|
161
161
|
}
|
|
162
162
|
|
package/package.json
CHANGED
package/test/all.js
CHANGED
|
@@ -311,6 +311,20 @@ test('keypair auth verify', async function (t) {
|
|
|
311
311
|
t.absent(keyPair.auth.verify(message, b4a.alloc(64)))
|
|
312
312
|
})
|
|
313
313
|
|
|
314
|
+
test('core caching after reopen regression', async function (t) {
|
|
315
|
+
const store = new Corestore(ram)
|
|
316
|
+
const core = store.get({ name: 'test-core' })
|
|
317
|
+
await core.ready()
|
|
318
|
+
|
|
319
|
+
core.close()
|
|
320
|
+
await core.opening
|
|
321
|
+
|
|
322
|
+
const core2 = store.get({ name: 'test-core' })
|
|
323
|
+
await core2.ready()
|
|
324
|
+
|
|
325
|
+
t.pass('did not infinite loop')
|
|
326
|
+
})
|
|
327
|
+
|
|
314
328
|
function tmpdir () {
|
|
315
329
|
return path.join(os.tmpdir(), 'corestore-' + Math.random().toString(16).slice(2))
|
|
316
330
|
}
|