diff --git a/indexes/common/utils.ts b/indexes/common/utils.ts index 24f13d9b..511ac304 100644 --- a/indexes/common/utils.ts +++ b/indexes/common/utils.ts @@ -91,7 +91,10 @@ export class ThreadPool implements AsyncIterable this.handle_worker_message(worker, message)); + worker.on("message", message => { + this.handle_worker_message(worker, message) + .catch(console.error); + }); return worker; } private async handle_worker_message(worker: Worker, message: MessageForThreadPool) { @@ -144,7 +147,7 @@ export class Funnel { await promise_factory(); this.count--; this.on_promise_finish(); - })(); + })().catch(console.error); } private on_promise_finish() { // run the next promise if needed diff --git a/indexes/cppref/create_index.ts b/indexes/cppref/create_index.ts index 9ea7676e..063d9b61 100644 --- a/indexes/cppref/create_index.ts +++ b/indexes/cppref/create_index.ts @@ -20,7 +20,7 @@ async function* walk_dir(dir: string): AsyncGenerator { } } -(async () => { +await (async () => { let index: cppref_index = { c: [], cpp: [] @@ -38,7 +38,7 @@ async function* walk_dir(dir: string): AsyncGenerator { let count = 0; - (async () => { + await (async () => { console.log("en.cppreference.com/w/c"); for await(const path of walk_dir("en.cppreference.com/w/c")) { if(path.endsWith(".html")) { diff --git a/indexes/cppref/worker.ts b/indexes/cppref/worker.ts index e37579a7..400276a9 100644 --- a/indexes/cppref/worker.ts +++ b/indexes/cppref/worker.ts @@ -82,8 +82,10 @@ async function handle_worker_message(message: MessageForWorker): }; } -parentPort.on("message", async (message: MessageForWorker) => { - parentPort!.postMessage(await handle_worker_message(message)); +parentPort.on("message", (message: MessageForWorker) => { + handle_worker_message(message) + .then(m => parentPort!.postMessage(m)) + .catch(console.error); }); parentPort.on("close", () => { diff --git a/indexes/man7/create_index.ts b/indexes/man7/create_index.ts index 1cd2c202..b7d3feeb 100644 --- a/indexes/man7/create_index.ts +++ b/indexes/man7/create_index.ts @@ -16,7 +16,7 @@ import { man7_index, WorkerJob, WorkerResponse } from "./types"; const seed_url = "https://man7.org/linux/man-pages/dir_all_by_section.html"; const base_url = "https://man7.org/linux/man-pages/"; -(async () => { +await (async () => { let man_entries: man7_index = []; if(fs.existsSync("man7_index.json")) { man_entries = JSON.parse(await fs.promises.readFile("man7_index.json", { encoding: "utf-8" })); diff --git a/indexes/man7/worker.ts b/indexes/man7/worker.ts index b2f88e95..9a0e6692 100644 --- a/indexes/man7/worker.ts +++ b/indexes/man7/worker.ts @@ -135,8 +135,10 @@ async function handle_worker_message(message: MessageForWorker): }; } -parentPort.on("message", async (message: MessageForWorker) => { - parentPort!.postMessage(await handle_worker_message(message)); +parentPort.on("message", (message: MessageForWorker) => { + handle_worker_message(message) + .then(m => parentPort!.postMessage(m)) + .catch(console.error); }); parentPort.on("close", () => {