Refresh stale IMS access token on collab WebSocket auth failures#937
Merged
Conversation
getAuthToken now reads window.adobeIMS.getAccessToken() live instead of returning the page-load snapshot that nx's loadIms() captures in onReady. On the collab WebSocket, refresh provider.protocols on connection-close so y-websocket's next reconnect picks up a fresh token without rebuilding the provider; 4403 stops reconnection. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
On a 4401 close, force an imslib refresh and bail (shouldConnect=false) if the resulting token is null or identical to what we just sent. Avoids infinite retries when the SSO session is gone or imslib has not rotated the token, and covers the anonymous-trying-private-doc path. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
When we bail out of the reconnect loop because imslib cannot produce a usable token, call handleSignIn() so the user is sent through IMS for re-auth instead of being silently stuck. Mirrors daFetch's 401 behaviour. Only fires when nx-ims is set, so anonymous users hitting a private doc are not punted into a sign-in flow they did not ask for. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The createConnection describe block's afterEach only restored a prior truthy value, leaving the key in place when a test had populated an originally-empty slot. handleSignIn writes nx-ims back, so the 4401 bail tests leaked the key into subsequent test files whose daFetch calls then crashed in initIms because getNx was unset there. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
chrissmillar
approved these changes
May 14, 2026
auniverseaway
approved these changes
May 14, 2026
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.
getAuthToken now reads window.adobeIMS.getAccessToken() live instead of returning the page-load snapshot that nx's loadIms() captures in onReady. On the collab WebSocket, refresh provider.protocols on connection-close so y-websocket's next reconnect picks up a fresh token without rebuilding the provider; 4403 stops reconnection.