mirror of
https://github.com/GoogleChromeLabs/squoosh.git
synced 2025-11-12 00:37:19 +00:00
These asserts weren't true
This commit is contained in:
@@ -92,7 +92,6 @@ export default class Processor {
|
|||||||
// If the worker is unused for 10 seconds, remove it to save memory.
|
// If the worker is unused for 10 seconds, remove it to save memory.
|
||||||
this._workerTimeoutId = self.setTimeout(
|
this._workerTimeoutId = self.setTimeout(
|
||||||
() => {
|
() => {
|
||||||
if (this._busy) throw Error("Worker shouldn't be busy");
|
|
||||||
if (!this._worker) return;
|
if (!this._worker) return;
|
||||||
this._worker.terminate();
|
this._worker.terminate();
|
||||||
this._worker = undefined;
|
this._worker = undefined;
|
||||||
@@ -104,14 +103,14 @@ export default class Processor {
|
|||||||
/** Abort the current job, if any */
|
/** Abort the current job, if any */
|
||||||
abortCurrent() {
|
abortCurrent() {
|
||||||
if (!this._busy) return;
|
if (!this._busy) return;
|
||||||
if (!this._worker || !this._abortRejector) {
|
if (!this._abortRejector) throw Error("There must be a rejector if it's busy");
|
||||||
throw Error("There must be a worker/rejector if it's busy");
|
|
||||||
}
|
|
||||||
this._abortRejector(new DOMException('Aborted', 'AbortError'));
|
this._abortRejector(new DOMException('Aborted', 'AbortError'));
|
||||||
this._worker.terminate();
|
|
||||||
this._worker = undefined;
|
|
||||||
this._abortRejector = undefined;
|
this._abortRejector = undefined;
|
||||||
this._busy = false;
|
this._busy = false;
|
||||||
|
|
||||||
|
if (!this._worker) return;
|
||||||
|
this._worker.terminate();
|
||||||
|
this._worker = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Off main thread jobs:
|
// Off main thread jobs:
|
||||||
|
|||||||
Reference in New Issue
Block a user