Skip to content

Commit b5cc9d9

Browse files
committed
bump init timeout to 10s
Apparently workers can take over a second to initialize in some environments, leading to unnecessary error messages Fixes #2
1 parent e88e3e2 commit b5cc9d9

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

source/worker.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ export class ClusterMemoryStoreWorker implements Store {
8989
}
9090

9191
cluster.worker.on('message', this.onMessage.bind(this))
92-
return this.send('init', [{ windowMs: this.windowMs }]).catch(
92+
return this.send('init', [{ windowMs: this.windowMs }], 10 * 1000).catch(
9393
(error: any) => {
9494
console.error(`${errorPrefix} failed to initialize`, error)
9595
},
@@ -131,11 +131,14 @@ export class ClusterMemoryStoreWorker implements Store {
131131
await this.send('resetKey', [key])
132132
}
133133

134-
private async send(command: Command, args: any[]): Promise<any> {
134+
private async send(
135+
command: Command,
136+
args: any[],
137+
timelimit = 1000,
138+
): Promise<any> {
135139
debug('Sending command %s with args %o', command, args)
136140
return new Promise((resolve, reject) => {
137141
const requestId = this.currentRequestId++
138-
const timelimit = 1000
139142
const timeoutId = setTimeout(() => {
140143
reject(
141144
new Error(

0 commit comments

Comments
 (0)