Skip to content

Commit 4a9e994

Browse files
committed
Make sure timeout does not fire twice.
1 parent 05a9b6e commit 4a9e994

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@ngnjs/queue",
3-
"version": "1.0.0-alpha.4",
4-
"description": "A lightweight NGN queue/taskrunner.",
3+
"version": "1.0.0-alpha.5",
4+
"description": "A lightweight NGN queue (taskrunner).",
55
"type": "module",
66
"main": "src/index.js",
77
"module": "index.js",

src/runner.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -297,9 +297,11 @@ export default class Queue extends EventEmitter {
297297
}
298298

299299
abort (timeout = false, task) {
300-
this.#cancelled = true
301-
clearTimeout(this.#timer)
302-
this._status = timeout ? 'timeout' : 'aborting'
303-
this.emit(timeout ? 'timeout' : 'aborted', task)
300+
if (!this.#cancelled) {
301+
this.#cancelled = true
302+
clearTimeout(this.#timer)
303+
this._status = timeout ? 'timeout' : 'aborting'
304+
this.emit(timeout ? 'timeout' : 'aborted', task)
305+
}
304306
}
305307
}

0 commit comments

Comments
 (0)