From a3817d01709c320ff8f64942de4246b2fbb3203f Mon Sep 17 00:00:00 2001 From: Kelly Selden <602423+kellyselden@users.noreply.github.com> Date: Thu, 8 Oct 2020 16:30:45 +0100 Subject: [PATCH] add notes preventing docker problems I spent half the day scratching my head on this one. I searched your repo for "docker" and found [this issue](https://github.com/andywer/threads.js/pull/206), which solved it. I would like to make it easier for others to find this solution. --- docs/usage.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/docs/usage.md b/docs/usage.md index 32b58459..7969ab54 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -166,6 +166,19 @@ const worker = await spawn(BlobWorker.fromText(MyWorker)) Bundle this module and you will obtain a stand-alone bundle that has its worker inlined. This is particularly useful for libraries using threads.js. +## Docker + +When running in docker, you may frequently run into the error: + +``` +Error: Timeout: Did not receive an init message from worker after 10000ms. Make sure the worker calls expose(). +``` + +Docker may need additional time to spawn the workers. There is two ways to do this: + +* set the environment variable `THREADS_WORKER_INIT_TIMEOUT=x0000` +* provide `spawn` with `options.timeout` ex. `spawn(new Worker('worker.js'), { timeout: x0000 })` + ## TypeScript ### Type-safe workers