fix(lsp): fix oxlint --lsp detection regression from Bun→Node migration#16425
Open
zerone0x wants to merge 1 commit intoanomalyco:devfrom
Open
fix(lsp): fix oxlint --lsp detection regression from Bun→Node migration#16425zerone0x wants to merge 1 commit intoanomalyco:devfrom
zerone0x wants to merge 1 commit intoanomalyco:devfrom
Conversation
…ation The oxlint LSP binary detection reads `oxlint --help` output to check whether the binary supports the `--lsp` flag. The original Bun code used `readableStreamToText(proc.stdout)` which worked correctly. When migrated to Node.js in 814c1d3, the pattern became: const proc = Process.spawn([lintBin, "--help"], { stdout: "pipe" }) await proc.exited if (proc.stdout) { const help = await text(proc.stdout) // may already be ended Node.js readable streams emit `end` before `exit` is guaranteed to have been consumed. By the time `text(proc.stdout)` is called sequentially after `await proc.exited`, the stream may have already emitted its `end` event, causing the async iterator inside `text()` to return immediately with empty content. The `--lsp` check then fails and the code falls through to looking for the separate `oxc_language_server` binary (also absent in many project setups), ultimately logging "oxlint not found, please install oxlint" even though `node_modules/.bin/oxlint` is present and supports `--lsp`. Fix: use `Process.run()` which reads stdout and stderr concurrently with the exit via `Promise.all`, matching the correct pattern already used in the rest of the Process utility. Also fold in stderr so detection works regardless of which stream the help text is written to. Fixes anomalyco#16309
|
I just stumbled about that same bug and came to the same conclusion. I do have one suggestion, instead of a (somewhat brittle) check on the I don't think parsing the |
6 tasks
|
I have implemented a fix here: #21887 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue for this PR
Closes #16309
Type of change
What does this PR do?
OpenCode detects whether an
oxlintbinary supports--lspby runningoxlint --helpand checking for--lspin the output. This check was broken by the Bun → Node.js process utility migration in 814c1d3.Root cause: The original Bun code:
was replaced with:
With Node.js
child_process, a piped stdoutReadablestream emitsendwhen all data has been written. By the timeawait proc.exitedresolves (processexitevent), the stream may have already emitted itsendevent. Callingtext(proc.stdout)afterwards initiates an async iterator that completes immediately on an already-ended stream, returning empty string. The--lspcheck fails, the code falls through to looking foroxc_language_server, which is also not installed, and the user sees:…even though
node_modules/.bin/oxlintexists and fully supports--lsp.Fix: Replace the sequential spawn→wait→read pattern with
Process.run(), which usesPromise.all([proc.exited, buffer(stdout), buffer(stderr)])— the correct concurrent pattern already established in the rest of the utility. As a bonus this also checks stderr, covering CLI builds that emit help text there.The
textimport fromnode:stream/consumersis no longer used and is removed.How did you verify your code works?
readableStreamToText→text(proc.stdout)Process.runusesPromise.allto read concurrently (correct pattern)Process.RunOptionsacceptsnothrow: trueto handle--helpexiting non-zero on some oxlint versionsScreenshots / recordings
N/A — LSP server startup logic
Checklist