fix: clamp setTimeout delays to avoid TimeoutOverflowWarning#3
Open
msallin wants to merge 1 commit intotkurki:masterfrom
Open
fix: clamp setTimeout delays to avoid TimeoutOverflowWarning#3msallin wants to merge 1 commit intotkurki:masterfrom
msallin wants to merge 1 commit intotkurki:masterfrom
Conversation
setTimeout delays are clamped to a 32-bit signed integer by Node.js. Values larger than 0x7fffffff trigger a TimeoutOverflowWarning and are silently coerced to 1ms, causing timers to fire immediately. When an mDNS record arrives with an oversized TTL, this caused cache entries to be evicted instantly and spammed host application logs with the warning. Clamp delays in TimerContainer.set/setLazy so oversized TTLs cap at the 24.8-day maximum instead. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes a
TimeoutOverflowWarningsurfaced in signalk-server logs (which depends ondnssd2):```
(node:18444) TimeoutOverflowWarning: 146811648000 does not fit into a 32-bit signed integer. Timeout duration was set to 1.
at TimerContainer.set (.../dnssd2/lib/TimerContainer.js:97:26)
at ExpiringRecordCollection._schedule (.../dnssd2/lib/ExpiringRecordCollection.js:398:33)
at ExpiringRecordCollection.add (.../dnssd2/lib/ExpiringRecordCollection.js:100:12)
at NetworkInterface._onMessage (.../dnssd2/lib/NetworkInterface.js:304:10)
```
Root cause
ExpiringRecordCollection._schedulecallssetTimeoutwithrecord.ttl * 1000. If an mDNS packet arrives with a TTL larger than ~24.8 days (0x7fffffffms), Node emitsTimeoutOverflowWarningand silently coerces the delay to 1ms — so the record expires immediately instead of at its real TTL. In the observed case the TTL was ~146,811,648 seconds (~4.6 years), likely from a malformed/rogue announcement on the network.Side effects:
Fix
Clamp delays in
TimerContainer.set/setLazyto0x7fffffffso oversized values never reachsetTimeoutraw. The timer still fires — just capped at the 24.8-day ceiling.Changes applied to both
src/(source) andlib/(babel build) to keep them in sync.Test plan
npm testTimeoutOverflowWarningin signalk-server logs after upgrading🤖 Generated with Claude Code