-
Notifications
You must be signed in to change notification settings - Fork 0
fix: harden dialer reconnect lifecycle + unblock Next build #342
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
1a5a7c4
fix: harden telnyx dialer reconnect lifecycle
coygg 8cdd746
fix: export functional src middleware shim for Next build
coygg 9f4708f
fix: restrict presence heartbeats to leader tab
coygg 0286ce5
fix: pass CSP nonce to theme provider
coygg 02c8c8e
fix: address dialer reconnect review feedback
coygg 210c48c
fix: sync local leader heartbeat kick
coygg afd9744
Merge origin/master into fix/dialer-reconnect-lifecycle
coygg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| import { describe, expect, it } from 'vitest' | ||
| import { | ||
| getLifecycleRecoveryDelay, | ||
| getRegistrationHealthCheckIntervalMs, | ||
| shouldRunInteractionRecovery, | ||
| } from '@/lib/telnyx-lifecycle' | ||
|
|
||
| describe('telnyx lifecycle helpers', () => { | ||
| it('returns the expected recovery delay for each lifecycle trigger', () => { | ||
| expect(getLifecycleRecoveryDelay('pageshow')).toBe(500) | ||
| expect(getLifecycleRecoveryDelay('online')).toBe(1000) | ||
| expect(getLifecycleRecoveryDelay('sdk-error')).toBe(1000) | ||
| expect(getLifecycleRecoveryDelay('socket-close-active')).toBe(1000) | ||
| expect(getLifecycleRecoveryDelay('socket-close-idle')).toBe(1000) | ||
| expect(getLifecycleRecoveryDelay('focus')).toBe(1000) | ||
| expect(getLifecycleRecoveryDelay('interaction')).toBe(1000) | ||
| expect(getLifecycleRecoveryDelay('makeCall')).toBe(1000) | ||
| expect(getLifecycleRecoveryDelay('visibilitychange')).toBe(1500) | ||
| expect(getLifecycleRecoveryDelay('post-call')).toBe(8000) | ||
| }) | ||
|
|
||
| it('uses the hidden interval when the tab is backgrounded', () => { | ||
| expect(getRegistrationHealthCheckIntervalMs('hidden', 60_000, 15_000)).toBe(15_000) | ||
| }) | ||
|
|
||
| it('uses the visible interval when the tab is visible or unknown', () => { | ||
| expect(getRegistrationHealthCheckIntervalMs('visible', 60_000, 15_000)).toBe(60_000) | ||
| expect(getRegistrationHealthCheckIntervalMs(undefined, 60_000, 15_000)).toBe(60_000) | ||
| }) | ||
|
|
||
| it('rate limits interaction-driven recovery checks', () => { | ||
| expect(shouldRunInteractionRecovery(10_000, 0)).toBe(true) | ||
| expect(shouldRunInteractionRecovery(4_999, 0)).toBe(false) | ||
| expect(shouldRunInteractionRecovery(6_000, 2_000)).toBe(false) | ||
| expect(shouldRunInteractionRecovery(7_001, 2_000)).toBe(true) | ||
| }) | ||
|
|
||
| it('accepts a custom cooldown for edge-case throttling', () => { | ||
| expect(shouldRunInteractionRecovery(2_000, 0, 2_500)).toBe(false) | ||
| expect(shouldRunInteractionRecovery(2_500, 0, 2_500)).toBe(true) | ||
| }) | ||
| }) |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| import { describe, expect, it } from 'vitest' | ||
|
|
||
| import { shouldSendPresenceHeartbeat } from '@/hooks/usePresence' | ||
|
|
||
| describe('shouldSendPresenceHeartbeat', () => { | ||
| it('allows heartbeats for the leader tab', () => { | ||
| expect(shouldSendPresenceHeartbeat(true)).toBe(true) | ||
| }) | ||
|
|
||
| it('blocks heartbeats for non-leader tabs', () => { | ||
| expect(shouldSendPresenceHeartbeat(false)).toBe(false) | ||
| }) | ||
| }) |
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
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This reschedules the periodic registration timeout unconditionally after
ensureRegistered('periodic')finishes, buthandleVisibilityChangealso starts a new timer whenever the tab visibility changes. If visibility changes while a periodic check is already in flight, you can end up with two independent timeout chains, which then keep running and cause redundantensureRegisteredcalls/reconnect attempts. This is reproducible under slow network checks plus quick hide/show tab transitions.Useful? React with 👍 / 👎.