fix(percy): skip launcher Percy setup when the BrowserStack CLI is running (SDK-7817) - #263
Conversation
…nning The CLI's PercyModule already downloads and runs the Percy CLI from ~/.browserstack/percy. The launcher's setupPercy downloaded a second copy into the same path while that executable was running, which fails with ETXTBSY on Linux and crashes the run. The launcher's Percy is unused in the CLI flow, so skip it there. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
Comment |
E2E verification — before / afterSetup: WDIO 9 + mocha, App Automate, 3 parallel Android devices,
Dashboard checks: all 3 sessions are present with the correct status on every build listed. Before: the launcher downloads Percy twice over the CLI's running Side benefit: in both before runs, the service-side Percy process was still running after wdio exited (orphaned, holding port 5338). That breaks the next build on reused or self-hosted machines. After the fix, the port is free once the run ends. Pending: the Linux before/after pair showing |
|
RUN_TESTS |
|
✅ Good to go
Change map (generated deterministically from the diff)graph LR
subgraph nwdio_browserstack_service["wdio-browserstack-service"]
npackages_browserstack_service_src_launcher_ts["launcher.ts<br/>~20 lines"]
npackages_browserstack_service_tests_launcher_test_ts["launcher.test.ts<br/>~20 lines"]
n_changeset_pr_263_md["pr-263.md<br/>~5 lines"]
end
↻ This verdict comment is the review anchor — it's updated in place on each run (the gate posts its status separately). — SDK PR Review Agent |
|
🟢 SDK PR Review gate is green — the SDK PR Review Agent has run on the current head commit (verdict: This gate confirms a review ran on the latest commit. The verdict itself is advisory — read the findings and use your judgement; it does not block merge. A native GitHub reviewer approval is still separately required by branch protection before this PR can merge. |
|
[SDK Wdio Test] TRA build state: passed | Stability 100% — verdict: success. Passed: 52, Failed: 0, Aggregate: 52. TRA: https://observability.browserstack.com/builds/uys99ocrohxg5de1ombemh3b4wraszcn3rvmfdpb |
|
[SDK Wdio Test] TRA build state: failed | Stability 81% — verdict: failure. Passed: 982, Failed: 226, Aggregate: 1210. TRA: https://observability.browserstack.com/builds/ymv23wmubh3f3398fmi2tmlvuibhxwaicib9yoqq |
| @@ -0,0 +1,5 @@ | |||
| --- | |||
There was a problem hiding this comment.
Why is this file needed?
There was a problem hiding this comment.
This file is automatically added for release notes purposes and get removed
yashdsaraf
left a comment
There was a problem hiding this comment.
Okay to add in regression but I'm not sure about the purpose of .changeset/pr-263.md file.
What is this about?
With Percy enabled and the BrowserStack CLI running, Percy was set up twice at the same path:
~/.browserstack/percyand starts it.setupPercy(launcher.ts,if (shouldSetupPercy)), which re-downloaded Percy into that same file while it was running.On Linux, writing over a running executable fails with
ETXTBSY: text file is busy, open '~/.browserstack/percy'. The error is unhandled and crashes the run (GitHub Actions and other Linux CI). macOS allows the overwrite silently, so it only showed up as aCorrupt percy binary, retryingloop.The launcher's Percy is never used in the CLI flow, because the worker-side
PercyHandleronly runs when the CLI is not running. This PR skips the launcher's Percy setup whenBrowserstackCLI.getInstance().isRunning(). The best-platform Percy selection still runs. The non-CLI flow is unchanged.Why it started now: binary 1.58.0 (browserstack-binary #1820, security fix SDK-7620) pins Percy CLI to v1.32.9 and no longer writes
~/.browserstack/percy.etag. Before that, the service found the binary's ETag, got a 304 fromreleases/latestand skipped its download. Now it always downloads.v8: not affected. On
v8, this Percy setup is already inside the!BrowserstackCLI.getInstance().isRunning()block.Related Jira task/s
Release (mandatory for every PR — required for the
ready-for-reviewlabel)Version bump: (required — tick exactly one)
Release notes type: (optional)
Release notes (customer-facing): (optional but encouraged)
ETXTBSY: text file is busy, open '~/.browserstack/percy'crashes on Linux when Percy is enabled.Release notes (internal): (required — engineer-facing; what actually changed / why)
setupPercy(download + start of a service-side Percy CLI) when the BrowserStack CLI is running, because the CLI's PercyModule owns the Percy process. This removes the second download over the running~/.browserstack/percy, which binary 1.58.0's removal ofpercy.etagturned into an ETXTBSY crash on Linux.Checklist
Testing
tests/launcher.test.ts. "CLI running → no service Percy" fails without the fix and passes with it; "CLI not running → service Percy still starts" passes.launcher.test.tsresult: 130/132 pass; the 2_uploadAppfailures also fail onmain.percy: true, clean home directory:Saved new ETag for percy binary, thenCorrupt percy binary, retrying).ETXTBSYbefore the fix and not after.PR Validations
Run Tests: Comment RUN_TESTS to trigger sanity tests.
🤖 Generated with Claude Code