You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Hardcoded 1000ms timeout causes failures in unstable network conditions #42
The current implementation has a hardcoded 1000ms timeout that makes the system fragile in unstable network conditions.
Problem Code
consttimeout=setTimeout(async()=>{awaitcleanup();constval=awaitctx.publisher.get(`${ctx.keyPrefix}:sentinel:${streamId}`);if(val===DONE_VALUE){resolve(null);}if(Date.now()-start>1000){controller.error(newError("Timeout waiting for ack"));}},1000);
Issues
Hardcoded timeout is inflexible: The 1000ms timeout cannot adapt to different network environments
Too aggressive: 1 second may be insufficient for high-latency or unstable networks
Confusing logic: The setTimeout delay and the timeout check both use 1000ms, meaning the timeout error will almost always trigger when the timer fires
Impact
Systems fail unnecessarily in slower network conditions
No way for users to configure timeout based on their environment
Production deployments in high-latency regions become unreliable
Suggested Solutions
Option 1: Configurable Timeout
consttimeout=ctx.config.ackTimeout||5000;// Default to 5sconsttimer=setTimeout(async()=>{awaitcleanup();constval=awaitctx.publisher.get(`${ctx.keyPrefix}:sentinel:${streamId}`);if(val===DONE_VALUE){resolve(null);}elseif(Date.now()-start>timeout){controller.error(newError("Timeout waiting for ack"));}},timeout);
Option 2: Retry with Backoff
Implement exponential backoff retry logic instead of a single hard timeout.
Environment
Network latency: Variable (100ms - 2000ms in our production)
This affects production stability
Would you be open to a PR implementing configurable timeouts?
Reacted by Dmytro Olefyrenko, strblr, mdnanocom and Aral Roca Gomez
Activity
olefirenko commentedon Apr 27, 2026
+1
mdnanocom commentedon Jun 25, 2026
+1
mdnanocom commentedon Jun 30, 2026
in fact i think the root cause to fix is #41
increasing timeout won't help in this case