Skip to content
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

[typescript] Allow client to understand other subprotocols #916

Merged
merged 6 commits into from
Jan 30, 2025

Conversation

bryfox
Copy link
Contributor

@bryfox bryfox commented Jan 30, 2025

Changelog

None

Docs

None

Description

This removes the "supported subprotocol" check performed after the handshake, instead relying on the underlying websocket client to advertise the correct subprotocol.

The FoxgloveClient already accepts a websocket client (IWebSocket), which is free to choose its advertised subprotocols. This change would allow it to be extended with backwards-compatible subprotocols (for example, v2).

This change is not breaking as long as existing clients are advertising the correct subprotocol.

@bryfox bryfox requested review from jtbandes and achim-k January 30, 2025 15:38
* A list subprotocols supported by this client. Typically, this will agree with the subprotocols
* advertised by the provided `IWebSocket` implementation.
*/
protected supportedSubprotocols: string[] = [FoxgloveClient.SUPPORTED_SUBPROTOCOL];
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SUPPORTED_SUBPROTOCOL is public, so arguably this should be too, but I'm not sure why the former is (or if it still needs to be).

Copy link
Member

@jtbandes jtbandes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, maybe we should just delete this check? I don’t think it’s really necessary anyway as the underlying WebSocket will handle the protocol as part of the handshake

@bryfox
Copy link
Contributor Author

bryfox commented Jan 30, 2025

Hm, maybe we should just delete this check? I don’t think it’s really necessary anyway as the underlying WebSocket will handle the protocol as part of the handshake

I think that's reasonable. I presume this is a check to make sure the provided ws client is advertising a subprotocol that this library understands (and so can provide a better error), but we could document instead.

@bryfox
Copy link
Contributor Author

bryfox commented Jan 30, 2025

I updated the PR and description to remove the check entirely.

@bryfox bryfox requested a review from jtbandes January 30, 2025 18:34
Co-authored-by: Jacob Bandes-Storch <jacob@foxglove.dev>
@bryfox bryfox merged commit 67a77c4 into main Jan 30, 2025
9 checks passed
@bryfox bryfox deleted the bryan/subprotocols branch January 30, 2025 22:31
bryfox added a commit that referenced this pull request Jan 31, 2025
### Changelog

Remove the explicit check for a supported subprotocol in
`FoxgloveClient`. Rely on the WS client to advertise the correct value
and the handshake to enforce it.

### Description

Version bump for #916
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants