Skip to content

Commit ee5f3db

Browse files
committed
Update worker-channel.js
1 parent f4acb40 commit ee5f3db

1 file changed

Lines changed: 17 additions & 4 deletions

File tree

worker/worker-channel.js

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ async function setupWorkerChannel() {
1919
await workerInstallPromise;
2020

2121

22+
let numOfRequests = 0;
23+
2224
async function pingWorkerForClientId() {
2325

2426
// get client ID from worker
@@ -30,14 +32,23 @@ async function setupWorkerChannel() {
3032
resp = '';
3133
console.log('%c[Client] Pinged ServiceWorker for installation', 'color: #80868b');
3234
}
33-
34-
if (!resp || !resp.clientId) {
35+
36+
if (numOfRequests < 500) {
3537

36-
return await pingWorkerForClientId();
38+
if (!resp || !resp.clientId) {
39+
40+
numOfRequests++;
41+
return await pingWorkerForClientId();
42+
43+
} else {
44+
45+
return resp.clientId;
46+
47+
}
3748

3849
} else {
3950

40-
return resp.clientId;
51+
return null;
4152

4253
}
4354

@@ -49,6 +60,8 @@ async function setupWorkerChannel() {
4960

5061
workerClientId = await workerInstallPromise;
5162

63+
if (workerClientId) console.debug('[Client] Found client ID:', workerClientId);
64+
5265
workerInstallPromise = null;
5366

5467

0 commit comments

Comments
 (0)