@chromahq/react 1.0.21 → 1.0.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +45 -7
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -174,8 +174,16 @@ function startHealthMonitor(deps) {
174
174
  } = deps;
175
175
  clearIntervalSafe(pingIntervalRef);
176
176
  consecutivePingFailuresRef.current = 0;
177
+ {
178
+ console.log(`[Bridge] Starting health monitor (ping every ${pingInterval}ms)`);
179
+ }
177
180
  pingIntervalRef.current = setInterval(async () => {
178
- if (!bridge.isConnected) return;
181
+ if (!bridge.isConnected) {
182
+ {
183
+ console.log("[Bridge] Health check skipped - not connected");
184
+ }
185
+ return;
186
+ }
179
187
  const alive = await bridge.ping();
180
188
  if (!pingIntervalRef.current) return;
181
189
  setIsServiceWorkerAlive(alive);
@@ -335,7 +343,15 @@ const BridgeProvider = ({
335
343
  );
336
344
  const scheduleSwRestartReconnect = useCallback(
337
345
  (connectFn) => {
338
- if (!isMountedRef.current) return;
346
+ {
347
+ console.log("[Bridge] scheduleSwRestartReconnect called, isMounted:", isMountedRef.current);
348
+ }
349
+ if (!isMountedRef.current) {
350
+ {
351
+ console.log("[Bridge] Not mounted, skipping SW restart reconnect");
352
+ }
353
+ return;
354
+ }
339
355
  swRestartRetryCountRef.current++;
340
356
  const delay = calculateBackoffDelay(
341
357
  swRestartRetryCountRef.current,
@@ -349,13 +365,24 @@ const BridgeProvider = ({
349
365
  }
350
366
  updateStatus("reconnecting");
351
367
  reconnectTimeoutRef.current = setTimeout(() => {
368
+ {
369
+ console.log("[Bridge] SW restart timeout fired, isMounted:", isMountedRef.current);
370
+ }
352
371
  if (isMountedRef.current) connectFn();
353
372
  }, delay);
354
373
  },
355
374
  [updateStatus]
356
375
  );
357
376
  const connect = useCallback(() => {
358
- if (isConnectingRef.current) return;
377
+ {
378
+ console.log("[Bridge] connect() called, isConnecting:", isConnectingRef.current);
379
+ }
380
+ if (isConnectingRef.current) {
381
+ {
382
+ console.log("[Bridge] Already connecting, skipping...");
383
+ }
384
+ return;
385
+ }
359
386
  isConnectingRef.current = true;
360
387
  cleanup();
361
388
  if (!chrome?.runtime?.connect) {
@@ -364,9 +391,15 @@ const BridgeProvider = ({
364
391
  return;
365
392
  }
366
393
  try {
394
+ if (BRIDGE_ENABLE_LOGS) {
395
+ console.log("[Bridge] Attempting chrome.runtime.connect...");
396
+ }
367
397
  const port = chrome.runtime.connect({ name: CONFIG.PORT_NAME });
368
398
  const immediateError = consumeRuntimeError();
369
399
  if (immediateError) throw new Error(immediateError);
400
+ if (BRIDGE_ENABLE_LOGS) {
401
+ console.log("[Bridge] Port created successfully:", port.name);
402
+ }
370
403
  portRef.current = port;
371
404
  let errorChecks = 0;
372
405
  errorCheckIntervalRef.current = setInterval(() => {
@@ -391,20 +424,25 @@ const BridgeProvider = ({
391
424
  port.onMessage.addListener(handleMessage);
392
425
  port.onDisconnect.addListener(() => {
393
426
  if (BRIDGE_ENABLE_LOGS) {
394
- console.warn("[Bridge] Disconnected");
427
+ console.warn("[Bridge] *** onDisconnect FIRED ***");
395
428
  }
396
429
  isConnectingRef.current = false;
397
430
  const disconnectError = consumeRuntimeError();
398
- if (disconnectError && BRIDGE_ENABLE_LOGS) {
399
- console.warn("[Bridge] Disconnect error:", disconnectError);
431
+ if (BRIDGE_ENABLE_LOGS) {
432
+ console.warn("[Bridge] Disconnect error:", disconnectError || "(none)");
433
+ console.warn("[Bridge] isMounted:", isMountedRef.current);
400
434
  }
401
435
  updateStatus("disconnected");
402
436
  cleanup();
403
437
  if (isMountedRef.current) {
404
438
  if (BRIDGE_ENABLE_LOGS) {
405
- console.log("[Bridge] Will retry until service worker is available...");
439
+ console.log("[Bridge] Scheduling SW restart reconnect...");
406
440
  }
407
441
  scheduleSwRestartReconnect(connect);
442
+ } else {
443
+ if (BRIDGE_ENABLE_LOGS) {
444
+ console.log("[Bridge] Not mounted, NOT scheduling reconnect");
445
+ }
408
446
  }
409
447
  });
410
448
  const triggerReconnect = () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chromahq/react",
3
- "version": "1.0.21",
3
+ "version": "1.0.22",
4
4
  "description": "React bindings for the Chroma Chrome extension framework",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",