Skip to content

Commit 7f4e29e

Browse files
committed
Change the "Terminate" worker-thread handler to an asynchronous function
This is a tiny bit shorter, which cannot hurt.
1 parent e8ab3cb commit 7f4e29e

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

src/core/worker.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -956,7 +956,7 @@ class WorkerMessageHandler {
956956
return pdfManager.cleanup(/* manuallyTriggered = */ true);
957957
});
958958

959-
handler.on("Terminate", function (data) {
959+
handler.on("Terminate", async function (data) {
960960
terminated = true;
961961

962962
const waitOn = [];
@@ -977,12 +977,11 @@ class WorkerMessageHandler {
977977
task.terminate();
978978
}
979979

980-
return Promise.all(waitOn).then(function () {
981-
// Notice that even if we destroying handler, resolved response promise
982-
// must be sent back.
983-
handler.destroy();
984-
handler = null;
985-
});
980+
await Promise.all(waitOn);
981+
// Notice that even if we destroying handler, resolved response promise
982+
// must be sent back.
983+
handler.destroy();
984+
handler = null;
986985
});
987986

988987
handler.on("Ready", function (data) {

0 commit comments

Comments
 (0)