Skip to content

Commit

Permalink
Remove monitor from the Set on close
Browse files Browse the repository at this point in the history
  • Loading branch information
MKPLKN committed Sep 6, 2024
1 parent 589bc24 commit f2aa6b5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/monitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ module.exports = class Monitor extends ReadyResource {
this.blobs.core.off('append', this._boundOnAppend)
this.blobs.core.off('upload', this._boundOnUpload)
this.blobs.core.off('download', this._boundOnDownload)
this.drive.monitors.delete(this)
}

async _onAppend () {
Expand Down
9 changes: 9 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1615,6 +1615,15 @@ test('upload/download can be monitored', async (t) => {
await mirror.drive.get(file)
})

test('monitor is removed from the Set on close', async (t) => {
const { drive } = await testenv(t.teardown)
const monitor = drive.monitor('/example.md')
await monitor.ready()
t.is(drive.monitors.size, 1)
await monitor.close()
t.is(drive.monitors.size, 0)
})

async function testenv (teardown) {
const corestore = new Corestore(RAM)
await corestore.ready()
Expand Down

0 comments on commit f2aa6b5

Please sign in to comment.