@broberg/lens-daemon 0.1.43 → 0.1.44

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/package.json +3 -3
  2. package/src/browser.ts +13 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@broberg/lens-daemon",
3
- "version": "0.1.43",
3
+ "version": "0.1.44",
4
4
  "description": "The Lens module of the cardmem daemon (flows, critic, coverage, capture sessions, the /lens/* routes and the cardmem-lens MCP) as a package. The daemon mounts createLensRouter(deps) + createLensMcpRouter(deps). Bun runtime.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -15,8 +15,8 @@
15
15
  "sharp": "^0.35.5",
16
16
  "turndown": "^7.2.4",
17
17
  "zod": "^3.23.8",
18
- "@broberg/lens-svg": "0.1.1",
19
- "@broberg/lens-engine": "0.14.1"
18
+ "@broberg/lens-engine": "0.14.1",
19
+ "@broberg/lens-svg": "0.1.1"
20
20
  },
21
21
  "devDependencies": {
22
22
  "@happy-dom/global-registrator": "^20.10.6",
package/src/browser.ts CHANGED
@@ -360,6 +360,16 @@ export interface LoadedExtension {
360
360
  export const EXTENSION_CHANNEL = 'chromium';
361
361
  const EXTENSION_LAUNCH_TIMEOUT_MS = 30_000;
362
362
  const EXTENSION_LAUNCH_ATTEMPTS = 2;
363
+ // Owner 25 Oct (jam, runs 2e72d502 + b64af4b1): a KEPT profile (cookies, cache,
364
+ // history of a real login) took longer than 30 s to start on M1 at load ~175 and
365
+ // the run failed, while a fresh temp profile started in 26 s. A slow start of a
366
+ // kept profile is waited for; the bound stays, so a launch that truly hangs still
367
+ // fails by name.
368
+ const PROFILE_LAUNCH_TIMEOUT_MS = 90_000;
369
+ /** Exported for test: the launch bound for a run, by whether it opens a kept profile. */
370
+ export function launchTimeoutFor(profile: string | undefined): number {
371
+ return profile ? PROFILE_LAUNCH_TIMEOUT_MS : EXTENSION_LAUNCH_TIMEOUT_MS;
372
+ }
363
373
 
364
374
  async function launchWithExtension(
365
375
  opts: WithPageOptions,
@@ -381,7 +391,7 @@ async function launchWithExtension(
381
391
  ...contextOptions(opts),
382
392
  headless: true,
383
393
  channel: EXTENSION_CHANNEL,
384
- timeout: EXTENSION_LAUNCH_TIMEOUT_MS,
394
+ timeout: launchTimeoutFor(profile),
385
395
  args: [
386
396
  `--disable-extensions-except=${extPath}`,
387
397
  `--load-extension=${extPath}`,
@@ -396,7 +406,7 @@ async function launchWithExtension(
396
406
  }
397
407
  if (!context) {
398
408
  throw new Error(
399
- `extension browser did not start (${EXTENSION_LAUNCH_ATTEMPTS} attempts × ${EXTENSION_LAUNCH_TIMEOUT_MS} ms): ${lastLaunchError}`,
409
+ `extension browser did not start (${EXTENSION_LAUNCH_ATTEMPTS} attempts × ${launchTimeoutFor(profile)} ms): ${lastLaunchError}`,
400
410
  );
401
411
  }
402
412
  // MV3 registers a service worker; MV2 a background page. Wait for whichever
@@ -468,7 +478,7 @@ async function launchRunBrowser(opts: WithPageOptions, b: RunBrowser): Promise<{
468
478
  const context = await trackChromeLaunch(b.channel, () => chromium.launchPersistentContext(userDataDir, {
469
479
  ...contextOptions({ ...opts, ...(userAgent ? { userAgent } : {}) }),
470
480
  ...runBrowserLaunchOptions(b),
471
- timeout: EXTENSION_LAUNCH_TIMEOUT_MS,
481
+ timeout: launchTimeoutFor(b.profile),
472
482
  }));
473
483
  return { context, userDataDir };
474
484
  } catch (err) {