Skip to content

Commit 9ee4729

Browse files
committed
Lint and don't be so defensive about try/catch - we'll add some instrumentation later
1 parent fd591aa commit 9ee4729

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

packages/ws-client/src/index.ts

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,7 @@ export function stop(resetRecordingId: boolean) {
6767
}
6868

6969
function removeRecordingId(): void {
70-
try {
71-
sessionStorage.removeItem(sessionStorageName);
72-
} catch (e) {}
70+
sessionStorage.removeItem(sessionStorageName);
7371
}
7472

7573
function getSetVisitorId() {
@@ -167,8 +165,8 @@ async function postData(
167165
const keepaliveLimit = 65000;
168166
let done = false;
169167
const responses = [];
170-
// eslint-disable-next-line no-constant-condition
171168
const toSend = [];
169+
// eslint-disable-next-line no-constant-condition
172170
while (true) {
173171
let body;
174172
if (buffer instanceof ArrayQueue) {
@@ -216,10 +214,8 @@ async function postData(
216214
if (badResponse) {
217215
let badResponseInfo = `${badResponse.status} ${badResponse.statusText}`;
218216
if (!badResponse.bodyUsed) {
219-
try {
220-
badResponseInfo +=
221-
'\nresponse body:' + JSON.stringify(await badResponse.json());
222-
} catch (e) {}
217+
badResponseInfo +=
218+
'\nresponse body:' + JSON.stringify(await badResponse.json());
223219
}
224220
throw new Error(`Bad response from POST: ${badResponseInfo}`);
225221
}
@@ -251,7 +247,7 @@ export function start(
251247
recordOptions.captureAssets.stylesheets = true; // inlineStylesheet as Asset
252248
}
253249

254-
let configEmit = recordOptions.emit;
250+
const configEmit = recordOptions.emit;
255251

256252
const handleMessage = (_: Websocket, ev: MessageEvent) => {
257253
const event = JSON.parse(ev.data);
@@ -352,7 +348,7 @@ export function start(
352348
if (typeof configEmit === 'function') {
353349
configEmit(event);
354350
} else if (typeof window[configEmit] === 'function') {
355-
(window[configEmit] as any)(event);
351+
(window[configEmit] as typeof recordOptions.emit)(event);
356352
} else {
357353
console.error('Could not understand emit config option:', configEmit);
358354
}
@@ -495,6 +491,7 @@ if (document && document.currentScript) {
495491
config.serverUrl = `https://${apiHost}/recordings/{recordingId}/ingest/ws`;
496492
}
497493
} catch {
494+
// eslint-ignore-next-line
498495
// maybe we are in a weird environment, we're likely gonna fail when we next call new URL on serverurl
499496
}
500497
}

0 commit comments

Comments
 (0)