-
Notifications
You must be signed in to change notification settings - Fork 11.3k
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 SDK] Fix websocket port #7637
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Ignored Deployment
|
7d14ac5
to
391122a
Compare
391122a
to
4fe69b8
Compare
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.
LGTM
@@ -13,7 +13,14 @@ import { Client as WsRpcClient } from 'rpc-websockets'; | |||
export const getWebsocketUrl = (httpUrl: string, port?: number): string => { | |||
const url = new URL(httpUrl); | |||
url.protocol = url.protocol.replace('http', 'ws'); | |||
url.port = (port ?? 9001).toString(); | |||
if (!url.port) { |
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.
URL ignores the default ports, for example doing something like
const url = new URL('http://example.com:80')
console.log(url.port); // ''
port will be empty same for https. So this will always throw if we use default port without passing the port parameter.
I don't think we should throw errors if port is not set. If not set it will mean the default port for the scheme (http/ws -> 80, https/wss -> 443)
[This change](#7637) breaks wallet and explorer. Doing [this](https://github.com/MystenLabs/sui/pull/7637/files#r1086606234) to fix it
[This change](#7637) breaks wallet and explorer. Doing [this](https://github.com/MystenLabs/sui/pull/7637/files#r1086606234) to fix it
closes #7546