Change the "Terminate" worker-thread handler to an asynchronous function

This is a tiny bit shorter, which cannot hurt.
This commit is contained in:
Jonas Jenwald 2026-03-06 11:24:12 +01:00
parent e8ab3cb335
commit 7f4e29ed22

View File

@ -956,7 +956,7 @@ class WorkerMessageHandler {
return pdfManager.cleanup(/* manuallyTriggered = */ true);
});
handler.on("Terminate", function (data) {
handler.on("Terminate", async function (data) {
terminated = true;
const waitOn = [];
@ -977,12 +977,11 @@ class WorkerMessageHandler {
task.terminate();
}
return Promise.all(waitOn).then(function () {
// Notice that even if we destroying handler, resolved response promise
// must be sent back.
handler.destroy();
handler = null;
});
await Promise.all(waitOn);
// Notice that even if we destroying handler, resolved response promise
// must be sent back.
handler.destroy();
handler = null;
});
handler.on("Ready", function (data) {