Skip to content

fix(server): Send permission denied event when token sync callback throws#1039

Closed
n-siddarth wants to merge 1 commit intoueberdosis:mainfrom
n-siddarth:main
Closed

fix(server): Send permission denied event when token sync callback throws#1039
n-siddarth wants to merge 1 commit intoueberdosis:mainfrom
n-siddarth:main

Conversation

@n-siddarth
Copy link

Problem

Token synchronization was introduced in #1001 . However, when the user-provided tokenSyncCallback throws, indicating a failed token validation attempt, current behavior is to just close the websocket connection. This prevents onAuthenticationFailed hooks in the provider from being called. Instead, onAuthenticationFailed is only called after the client attempts to reconnect to the server after some duration.

Solution

Before closing the websocket connection on a failed token validation attempt, we first send a permission denied message back to the client and then close the connection. This causes the provider to call onAuthenticationFailed hooks which is expected behavior.

@n-siddarth
Copy link
Author

@janthurau I was wondering, would it make more sense to implement this logic in the server or the provider? Ideally, the provider should respond to the Unauthorized CloseEvent, which does get emitted, but this doesn't seem to be the case as of now.

@n-siddarth
Copy link
Author

n-siddarth commented Dec 17, 2025

Had another thought, we could have onTokenSynced and onTokenSyncedFailed hooks on the provider too 🤔. This would make the provider behavior more consistent with the server behavior.

@n-siddarth n-siddarth closed this by deleting the head repository Jan 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant