From 5f63d2b822e786265bd97da0c8d54f63b581388b Mon Sep 17 00:00:00 2001 From: Asher Date: Mon, 16 Mar 2020 12:52:18 -0500 Subject: [PATCH] Fix custom socket path --- src/browser/socket.ts | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/browser/socket.ts b/src/browser/socket.ts index 764f8c90..67c834e2 100644 --- a/src/browser/socket.ts +++ b/src/browser/socket.ts @@ -44,7 +44,7 @@ export class ReconnectingSocket { private _binaryType: typeof WebSocket.prototype.binaryType = "arraybuffer" - public constructor(private customPath?: string, public readonly id: string = generateUuid(4)) { + public constructor(private path: string, public readonly id: string = generateUuid(4)) { // On Firefox the socket seems to somehow persist a page reload so the close // event runs and we see "attempting to reconnect". if (typeof window !== "undefined") { @@ -155,12 +155,8 @@ export class ReconnectingSocket { this.logger.info(`retrying in ${this.retryDelay}ms...`) } setTimeout(() => { - this.logger.info("connecting...") - const socket = new WebSocket( - `${location.protocol === "https:" ? "wss" : "ws"}://${location.host}${this.customPath || location.pathname}${ - location.search ? `?${location.search}` : "" - }`, - ) + this.logger.info("connecting...", field("path", this.path)) + const socket = new WebSocket(this.path) const reject = (): void => { _reject(new Error("socket closed"))