Skip to content

fix(lsp): fix oxlint LSP race condition on --help stdout read#21887

Open
offlinehacker wants to merge 1 commit intoanomalyco:devfrom
offlinehacker:fix/oxlint-lsp-race-condition
Open

fix(lsp): fix oxlint LSP race condition on --help stdout read#21887
offlinehacker wants to merge 1 commit intoanomalyco:devfrom
offlinehacker:fix/oxlint-lsp-race-condition

Conversation

@offlinehacker
Copy link
Copy Markdown

@offlinehacker offlinehacker commented Apr 10, 2026

Issue for this PR

Closes #17597
Closes #16309

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

The oxlint LSP never starts because the detection code awaits proc.exited before reading proc.stdout. By the time text(proc.stdout) runs, the stream is already drained, yielding an empty string — so help.includes("--lsp") is always false.

Fix: read stdout concurrently with proc.exited via Promise.all. Also switched to Process.spawn with { stdout: "pipe" } instead of the LSP spawn wrapper (which forces stdin/stdout/stderr pipes and is meant for running the actual LSP server, not a one-off --help check). Removed the oxc_language_server fallback since it's not a bin entry in the oxlint npm package.

How did you verify your code works?

  1. Standalone Node.js reproduction confirming the sequential read yields 0 bytes while Promise.all yields 6142 bytes with --lsp present.
  2. Ran opencode run via bun dev against a test project with .oxlintrc.json and a .ts file. Logs confirm the LSP starts:
INFO service=lsp serverID=oxlint spawned lsp server
INFO service=lsp.client serverID=oxlint starting client
INFO service=lsp.client serverID=oxlint sending initialize
INFO service=lsp.client serverID=oxlint initialized

Screenshots / recordings

Not a UI change.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions github-actions bot added the needs:compliance This means the issue will auto-close after 2 hours. label Apr 10, 2026
@github-actions
Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

Related PR Found

#16425 - fix(lsp): fix oxlint --lsp detection regression from Bun→Node migration

This PR is related to the current PR (#21887) as it addresses a previous oxlint LSP detection issue from a Bun to Node migration. The current PR appears to be fixing a race condition in that same detection logic, so there may be shared context or related fixes between them.

@github-actions github-actions bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Apr 10, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

Read stdout concurrently with proc.exited using Promise.all to prevent
the stream from being drained before reading. Also use Process.spawn
with explicit { stdout: "pipe" } instead of the LSP spawn wrapper,
and remove the dead oxc_language_server fallback path since it is not
shipped as a bin entry in the oxlint npm package.

Fixes anomalyco#17597
Fixes anomalyco#16309
@offlinehacker offlinehacker force-pushed the fix/oxlint-lsp-race-condition branch from 87fde81 to 3181a2b Compare April 10, 2026 15:24
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.

BUG: Oxlint Fails to load due to race condition on --help call Built-in oxlint LSP checks project dependency but does not use project binary

1 participant