Skip to content

Commit 3662b65

Browse files
authored
Straighten init timeout error message (#293)
1 parent 7bf8ed9 commit 3662b65

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/master/spawn.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,8 @@ export async function spawn<Exposed extends WorkerFunction | WorkerModule<any> =
146146
): Promise<ExposedToThreadType<Exposed>> {
147147
debugSpawn("Initializing new thread")
148148

149-
const initMessage = await withTimeout(receiveInitMessage(worker), options && options.timeout ? options.timeout : initMessageTimeout, `Timeout: Did not receive an init message from worker after ${initMessageTimeout}ms. Make sure the worker calls expose().`)
149+
const timeout = options && options.timeout ? options.timeout : initMessageTimeout
150+
const initMessage = await withTimeout(receiveInitMessage(worker), timeout, `Timeout: Did not receive an init message from worker after ${timeout}ms. Make sure the worker calls expose().`)
150151
const exposed = initMessage.exposed
151152

152153
const { termination, terminate } = createTerminator(worker)

0 commit comments

Comments
 (0)