Skip to content

test(cli): fix Windows race in concurrent daemon lock fixture - #3456

Merged
shrey150 merged 1 commit into
mainfrom
codex/cli-lock-fixture-windows
Nov 14, 2026
Merged

shrey150 merged 1 commit into
mainfrom
codex/cli-lock-fixture-windows

Conversation

@shrey150

@shrey150 shrey150 commented Nov 13, 2026 •

Copy link
Copy Markdown
Collaborator

why

The concurrent-daemon test intermittently fails on Windows with EPERM: its fixture can remove the lock while the code under test is inspecting it or attempting to acquire it again.

what changed

Synchronizes the fixture in packages/cli/tests/driver-session.test.ts: wait until the occupied lock has been inspected, pause the next acquisition while starting the fake daemon and removing the lock, then resume in finally. The test still exercises real lock contention and retains every assertion.

This changes only test synchronization. No changeset is needed because no shipped behavior changes.

test plan

  • Driver-session suite: 24 passed.
  • Changed-file lint, formatting, and diff checks.
  • CI passing at 75bee119c, including Linux/Windows contract and Chrome smoke tests; automated review found no issues.

@changeset-bot

changeset-bot Bot commented Nov 13, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 75bee11

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.
Architecture diagram
sequenceDiagram
    participant Test as Concurrent Driver Test
    participant Fixture as Lock Fixture
    participant FS as fs Module
    participant Code as Code Under Test
    participant Daemon as Fake Daemon

    alt waitsForLock set
        Fixture->>FS: writeFile(lockPath, pid)
        activate FS
        FS-->>Fixture: lock file created
        deactivate FS

        Fixture->>FS: spyOn(open)
        FS->>Code: acquireLock() - open(lockPath, "wx")
        alt File exists (EEXIST)
            FS-->>Code: error EEXIST
            Code->>Fixture: sawOccupiedLock = true
            Code->>Fixture: resolve waitingForLock
            Fixture->>Fixture: await fixtureReady (paused)
        else No lock yet
            FS-->>Code: open success
        end
    end

    Note over Test,Fixture: Fixture resumes after lock is occupied

    Test->>Fixture: await waitingForLock
    activate Fixture
    Fixture->>Daemon: listen()
    activate Daemon
    Daemon-->>Fixture: started
    deactivate Daemon

    Fixture->>FS: rm(lockPath)
    activate FS
    FS-->>Fixture: removed
    deactivate FS

    Fixture->>Fixture: finally - resumeLockAcquisition()
    Fixture->>Code: resume retry
    activate Code
    Code->>FS: open(lockPath, "wx") - retry
    alt Lock removed
        FS-->>Code: success
        Code-->>Test: resolved result
    else Lock still present
        FS-->>Code: error EEXIST
    end
    deactivate Code
    deactivate Fixture
Loading

View guided diff | Turn on auto-fix | Re-trigger cubic

@shrey150
shrey150 merged commit 6f2686d into main Nov 14, 2026
29 checks passed
@shrey150
shrey150 deleted the codex/cli-lock-fixture-windows branch November 14, 2026 00:21
shrey150 added a commit that referenced this pull request Nov 18, 2026
# why

Help users find the Stagehand and Browse CLI community when they check
help or encounter an unexpected error. This PR is stacked on #3450,
which adds `browse discord` and the updated community invitation.

# what changed

Adds this footer to root help (`browse` and `browse --help`):

```text
COMMUNITY
  Discord: https://discord.gg/stagehand
  Report a bug: https://github.com/browserbase/stagehand/issues
```

Unexpected runtime errors also print this hint to stderr:

```text
Get help: https://discord.gg/stagehand · Report a bug: https://github.com/browserbase/stagehand/issues
```

The footer appears only on root help. Usage errors, command-not-found,
and expected `CommandFailure` errors omit the support hint.

For review, `packages/cli/src/help.ts` adds the footer and
`packages/cli/src/base.ts` handles the error hint. Includes a **patch
changeset for `browse`**.

# test plan

- [x] CLI TypeScript build and oclif manifest generation.
- [x] Discord, opener, help, and CLI surface tests: **83 passed**.
- [x] Unexpected-error subprocess case verifies both support links on
stderr, the original error, and exit code 1; removing the hint makes the
test fail.
- [x] Changed-file formatting and lint.
- [x] CI passing at `5c8de796d`, including Linux/Windows contracts,
Chrome smoke tests, regression tests, and automated review. Windows
contracts passed on rerun after the existing daemon-lock fixture
`EPERM`; the isolated test fix is #3456.

---------

Co-authored-by: Cursor Agent <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants