Skip to content

Commit 5f63d2b

Browse files
committed
Fix custom socket path
1 parent db4a4f0 commit 5f63d2b

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

src/browser/socket.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export class ReconnectingSocket {
4444

4545
private _binaryType: typeof WebSocket.prototype.binaryType = "arraybuffer"
4646

47-
public constructor(private customPath?: string, public readonly id: string = generateUuid(4)) {
47+
public constructor(private path: string, public readonly id: string = generateUuid(4)) {
4848
// On Firefox the socket seems to somehow persist a page reload so the close
4949
// event runs and we see "attempting to reconnect".
5050
if (typeof window !== "undefined") {
@@ -155,12 +155,8 @@ export class ReconnectingSocket {
155155
this.logger.info(`retrying in ${this.retryDelay}ms...`)
156156
}
157157
setTimeout(() => {
158-
this.logger.info("connecting...")
159-
const socket = new WebSocket(
160-
`${location.protocol === "https:" ? "wss" : "ws"}://${location.host}${this.customPath || location.pathname}${
161-
location.search ? `?${location.search}` : ""
162-
}`,
163-
)
158+
this.logger.info("connecting...", field("path", this.path))
159+
const socket = new WebSocket(this.path)
164160

165161
const reject = (): void => {
166162
_reject(new Error("socket closed"))

0 commit comments

Comments
 (0)