@hmharness/browser 0.23.22 → 0.23.24

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/cdp.js +19 -0
  2. package/package.json +2 -2
package/dist/cdp.js CHANGED
@@ -184,6 +184,25 @@ export class CdpBrowser {
184
184
  return Buffer.from(r.data, 'base64');
185
185
  }
186
186
  async close() {
187
+ // dropSocket() nulls the field WITHOUT closing the socket — the WS
188
+ // would stay open and hold the event loop (found by the extension
189
+ // real-browser test: runner hung after PASS until this was fixed).
190
+ // Bounded by a 1s race: a socket whose peer already died may never
191
+ // deliver a close event.
192
+ const ws = this.ws;
187
193
  this.dropSocket();
194
+ if (ws && (ws.readyState === WebSocket.OPEN || ws.readyState === WebSocket.CONNECTING)) {
195
+ await new Promise((resolve) => {
196
+ const t = setTimeout(resolve, 1_000);
197
+ ws.addEventListener('close', () => { clearTimeout(t); resolve(); }, { once: true });
198
+ try {
199
+ ws.close();
200
+ }
201
+ catch {
202
+ clearTimeout(t);
203
+ resolve(); /* already dead */
204
+ }
205
+ });
206
+ }
188
207
  }
189
208
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hmharness/browser",
3
- "version": "0.23.22",
3
+ "version": "0.23.24",
4
4
  "description": "hmharness BrowserOS driver — discovers, trust-pins and launches the BrowserOS AI browser (Chromium fork), then drives it over the Chrome DevTools Protocol. Client only, zero dependencies, dedicated profile: the user's daily browser is never touched.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -15,7 +15,7 @@
15
15
  "build": "tsc -p tsconfig.build.json"
16
16
  },
17
17
  "dependencies": {
18
- "@hmharness/kernel": "0.23.22"
18
+ "@hmharness/kernel": "0.23.24"
19
19
  },
20
20
  "files": [
21
21
  "dist"