typescript
type TimeoutConfig = Partial<Record<BuiltInTimeoutKey | keyof TDefs, number>>Timeout configuration allowing per-message-type timeouts.
Built-in keys:
WORKER_STARTUP: Time to wait for worker to start (default: 10s)SERVER_CONNECT: Time for server to wait for host connection (default: 30s)WORKER_MESSAGE: Default timeout for all messages (default: 5min)
You can also specify timeouts for specific message types by their key name. Message-specific timeouts take precedence over WORKER_MESSAGE.
Examples
typescript
const worker = await createWorker<MyMessages>({
script: './worker.js',
timeout: {
WORKER_STARTUP: 5000, // 5s startup
SERVER_CONNECT: 10000, // 10s for server to wait for host
WORKER_MESSAGE: 60000, // 1min default for messages
'slowOperation': 600000, // 10min for specific message type
}
});