@farmslot/adapter-web 0.19.38 → 0.19.39

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
@@ -6,6 +6,10 @@ All notable changes to `@farmslot/adapter-web` are tracked here.
6
6
 
7
7
  - Active-development baseline; add user-facing changes here before release or package publication.
8
8
 
9
+ ## 0.19.39 - 2026-12-02
10
+
11
+ - Clear detached browser launch quarantine markers when synchronous `open` or `spawn` fails and no process holds the target profile, preventing permanent profile/port quarantine after transient launch failures such as a locked macOS GUI session.
12
+
9
13
  ## 0.19.38 - 2026-11-30
10
14
 
11
15
  - Depend on `@farmslot/adapter-sdk` 0.31.5, so consumers resolve one copy of `@farmslot/protocol` and `@farmslot/recipe-runner`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@farmslot/adapter-web",
3
- "version": "0.19.38",
3
+ "version": "0.19.39",
4
4
  "description": "Web platform adapter for Farmslot recipes: resolve and launch an isolated Chromium, own its CDP port, load unpacked extensions, and keep macOS focus.",
5
5
  "type": "commonjs",
6
6
  "exports": {
@@ -87,9 +87,9 @@
87
87
  "prepublishOnly": "node ../../scripts/quality/check-farmslot-package-readiness.mjs --publish --packages @farmslot/adapter-web"
88
88
  },
89
89
  "dependencies": {
90
- "@farmslot/adapter-sdk": "0.31.5",
91
- "@farmslot/protocol": "0.92.6",
92
- "@farmslot/recipe-runner": "0.52.8",
90
+ "@farmslot/adapter-sdk": "0.31.6",
91
+ "@farmslot/protocol": "0.93.0",
92
+ "@farmslot/recipe-runner": "0.52.9",
93
93
  "ws": "^8.18.0"
94
94
  },
95
95
  "devDependencies": {
@@ -220,6 +220,13 @@ function runLaunch(opts, acquireLock) {
220
220
  clearDetachedLaunchUnproven(profile);
221
221
  if (!activeValidationLease) clearValidationPortQuarantine(cdpPort, profile);
222
222
  };
223
+ const clearLaunchMarkersIfProfileUnused = () => {
224
+ try {
225
+ if (profileProcessPids(profile).length === 0) clearLaunchMarkers();
226
+ } catch {
227
+ // Keep quarantine markers conservatively if profile-process inspection fails.
228
+ }
229
+ };
223
230
 
224
231
  const initialUrl =
225
232
  opts.startUrl || extensionPageUrl(extensionDir, opts.homePage) || 'chrome://extensions/';
@@ -327,21 +334,47 @@ function runLaunch(opts, acquireLock) {
327
334
  beginDetachedLaunch(cdpPort, profile, activeValidationLease);
328
335
  opts.progress({ message: 'starting the browser' });
329
336
  if (application) {
330
- execFileSync('open', macBackgroundOpenArgs(application, chromeArgs), {
331
- env: sanitizedChildEnv(),
332
- stdio: ['ignore', logFd, logFd],
333
- });
337
+ try {
338
+ execFileSync('open', macBackgroundOpenArgs(application, chromeArgs), {
339
+ env: sanitizedChildEnv(),
340
+ stdio: ['ignore', logFd, logFd],
341
+ });
342
+ } catch (error) {
343
+ if (isConfirmedOpenRejection(error)) clearLaunchMarkersIfProfileUnused();
344
+ throw error;
345
+ }
334
346
  // `open` can return before the browser shows up in ps.
335
347
  browserPid = awaitOwnedListener({ waitForAppearanceMs: 400 }, 5000);
336
348
  } else {
337
- const child = spawn(opts.chromeBin, chromeArgs, {
338
- detached: true,
339
- env: sanitizedChildEnv(),
340
- stdio: ['ignore', logFd, logFd],
341
- });
349
+ let child;
350
+ try {
351
+ child = spawn(opts.chromeBin, chromeArgs, {
352
+ detached: true,
353
+ env: sanitizedChildEnv(),
354
+ stdio: ['ignore', logFd, logFd],
355
+ });
356
+ } catch (error) {
357
+ clearLaunchMarkersIfProfileUnused();
358
+ throw error;
359
+ }
360
+ // Attach an error handler so an async spawn failure (e.g. EACCES, ENOENT) never
361
+ // becomes an unhandled EventEmitter error after this synchronous launcher returns.
362
+ if (typeof child.once === 'function') child.once('error', () => {});
363
+ if (!child.pid) {
364
+ clearLaunchMarkersIfProfileUnused();
365
+ let detail = 'process did not start';
366
+ try {
367
+ fs.accessSync(opts.chromeBin, fs.constants.X_OK);
368
+ } catch (accessError) {
369
+ detail = accessError.code ?? accessError.message;
370
+ }
371
+ throw new Error(
372
+ `Could not start ${path.basename(opts.chromeBin)}: ${detail}. Next: check permissions for ${opts.chromeBin}, then ${rerun}`,
373
+ );
374
+ }
342
375
  child.unref();
343
376
  // spawn returns after exec, so the browser is in ps at once.
344
- browserPid = awaitOwnedListener({ extraPids: child.pid ? [child.pid] : [] }, 0);
377
+ browserPid = awaitOwnedListener({ extraPids: [child.pid] }, 0);
345
378
  }
346
379
  if (loadsOverCdp)
347
380
  cdpLoad = loadExtensionOverCdp(opts, browserPid, initialUrl, clearLaunchMarkers);
@@ -554,6 +587,13 @@ function beginDetachedLaunch(port, profile, activeLease) {
554
587
  }
555
588
  }
556
589
 
590
+ function isConfirmedOpenRejection(error) {
591
+ if (!error || typeof error !== 'object') return false;
592
+ if (error.signal != null || error.code === 'ETIMEDOUT') return false;
593
+ if (typeof error.status === 'number' && error.status !== 0) return true;
594
+ return error.code === 'ENOENT' || error.code === 'EACCES';
595
+ }
596
+
557
597
  function macApplicationForExecutable(executable) {
558
598
  let current = path.resolve(executable);
559
599
  while (current !== path.dirname(current)) {