From 20ba0697025b7fe21e6cef9036ec3dfaaaa90a53 Mon Sep 17 00:00:00 2001 From: Chris Toshok Date: Wed, 30 Oct 2024 11:47:31 -0700 Subject: [PATCH] we need to guard these window accesses to --- packages/protocol/socket.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/protocol/socket.ts b/packages/protocol/socket.ts index 540701f387d..1c6c94a7bdd 100644 --- a/packages/protocol/socket.ts +++ b/packages/protocol/socket.ts @@ -250,7 +250,9 @@ export async function sendMessage( } const doSend = makeInfallible(message => { - window.performance?.mark(`${message.method}_start`); + if (typeof window !== "undefined") { + window.performance?.mark(`${message.method}_start`); + } const stringified = JSON.stringify(message); gSentBytes += stringified.length; @@ -328,8 +330,10 @@ function socketDataHandler(data: string) { const { method, resolve } = gMessageWaiters.get(msg.id)!; gSessionCallbacks?.onResponse(msg); - window.performance?.mark(`${method}_end`); - window.performance?.measure(method, `${method}_start`, `${method}_end`); + if (typeof window !== "undefined") { + window.performance?.mark(`${method}_end`); + window.performance?.measure(method, `${method}_start`, `${method}_end`); + } gMessageWaiters.delete(msg.id); resolve(msg);