Skip to content

Commit a68a6f3

Browse files
committed
Flush processing should always happen
1 parent 702d6a4 commit a68a6f3

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

index.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,12 @@ class CorestoreNetworker extends Nanoresource {
5656
announce: opts.announce,
5757
lookup: opts.lookup
5858
})
59-
if (opts.flush !== false) {
59+
60+
const flushedProm = flush.bind(this)()
61+
if (opts.flush !== false) await flushedProm
62+
else flushedProm.catch(() => {})
63+
64+
async function flush () {
6065
await new Promise((resolve, reject) => {
6166
this.swarm.flush(err => {
6267
if (err) reject(err)
@@ -235,7 +240,7 @@ class CorestoreNetworker extends Nanoresource {
235240
}
236241

237242
async _configure (discoveryKey, opts) {
238-
if (!this.swarm) await this.open()
243+
if (!this.swarm) this.open()
239244
if (this.swarm && this.swarm.destroyed) return
240245

241246
const config = {

0 commit comments

Comments
 (0)