@btraut/browser-bridge 0.7.1 → 0.7.2

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.
package/CHANGELOG.md CHANGED
@@ -8,6 +8,12 @@ The format is based on "Keep a Changelog", and this project adheres to Semantic
8
8
 
9
9
  _TBD_
10
10
 
11
+ ## [0.7.2] - 2026-02-12
12
+
13
+ ### Fixed
14
+
15
+ - Core debugger bridge now self-heals stale attach state: when a command fails with "Debugger is not attached to the requested tab.", it marks the tab detached, re-attaches once, and retries the command once. It also clears cached attachment state after extension disconnects to avoid false "attached" assumptions that can trigger inspect recovery loops/timeouts.
16
+
11
17
  ## [0.7.1] - 2026-02-11
12
18
 
13
19
  ### Fixed
package/dist/api.js CHANGED
@@ -4350,7 +4350,7 @@ var DebuggerBridge = class {
4350
4350
  return attachResult;
4351
4351
  }
4352
4352
  try {
4353
- const response = await this.bridge.requestDebugger(
4353
+ const runCommand = async () => await this.bridge.requestDebugger(
4354
4354
  "debugger.command",
4355
4355
  {
4356
4356
  tab_id: tabId,
@@ -4359,6 +4359,15 @@ var DebuggerBridge = class {
4359
4359
  },
4360
4360
  timeoutMs
4361
4361
  );
4362
+ let response = await runCommand();
4363
+ if (response.status === "error" && this.shouldRetryAfterStaleAttach(response.error)) {
4364
+ this.markDetached(tabId);
4365
+ const reattach = await this.attach(tabId);
4366
+ if (!reattach.ok) {
4367
+ return reattach;
4368
+ }
4369
+ response = await runCommand();
4370
+ }
4362
4371
  if (response.status === "error") {
4363
4372
  const error = response.error ?? {
4364
4373
  code: "INSPECT_UNAVAILABLE",
@@ -4461,6 +4470,9 @@ var DebuggerBridge = class {
4461
4470
  }
4462
4471
  handleBridgeError(error) {
4463
4472
  if (error instanceof ExtensionBridgeError) {
4473
+ if (error.code === "EXTENSION_DISCONNECTED") {
4474
+ this.markAllDetached();
4475
+ }
4464
4476
  const info2 = toDriveError(error);
4465
4477
  this.recordError(info2);
4466
4478
  return info2;
@@ -4473,6 +4485,18 @@ var DebuggerBridge = class {
4473
4485
  this.recordError(info);
4474
4486
  return info;
4475
4487
  }
4488
+ shouldRetryAfterStaleAttach(error) {
4489
+ if (!error) return false;
4490
+ if (error.code !== "FAILED_PRECONDITION" && error.code !== "INSPECT_UNAVAILABLE") {
4491
+ return false;
4492
+ }
4493
+ return error.message.toLowerCase().includes("not attached");
4494
+ }
4495
+ markAllDetached() {
4496
+ for (const tabId of this.tabs.keys()) {
4497
+ this.markDetached(tabId);
4498
+ }
4499
+ }
4476
4500
  };
4477
4501
 
4478
4502
  // packages/core/src/server.ts