Skip to content

Commit

Permalink
watcher async iterator must exit on close (#165)
Browse files Browse the repository at this point in the history
* watcher async iterator must exit on close

* resolve on change if closing
  • Loading branch information
chm-diederichs authored Sep 25, 2024
1 parent 852710e commit df4ce84
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1262,7 +1262,7 @@ class Watcher extends ReadyResource {
_onappend () {
// TODO: this is a light hack / fix for non-sparse session reporting .length's inside batches
// the better solution is propably just to change non-sparse sessions to not report a fake length
if (!this.core.isAutobase && (!this.core.core || this.core.core.tree.length !== this.core.length)) return
if (!this.closing && !this.core.isAutobase && (!this.core.core || this.core.core.tree.length !== this.core.length)) return

const resolve = this._resolveOnChange
this._resolveOnChange = null
Expand Down Expand Up @@ -1298,6 +1298,8 @@ class Watcher extends ReadyResource {
while (true) {
await this._waitForChanges()

if (this.closing) return { value: undefined, done: true }

if (this._updateOnce) {
this._updateOnce = false
await this.bee.update({ wait: true })
Expand Down

0 comments on commit df4ce84

Please sign in to comment.