Fix format-on-save to avoid unnecessary oxlint requests#310
Conversation
|
hello and thanks for this PR! Can you explain a bit more when exactly we skip the oxlint code actions? We already check on Happy to hear your thoughts :) |
|
We skip before sending the request to oxlint in these cases:
We still forward unscoped/manual requests, quick fixes, explicit The oxlint-side "editor.codeActionsOnSave": {},
"editor.formatOnSave": truepressing save should only invoke oxfmt formatting; oxlint should not receive code-action or diagnostic requests from that save path. That said, I agree it would be good to also add a protocol-level guard in oxlint so other editors benefit. I think the oxlint server can cheaply return |
|
Thank you for the detail, I agree with you that the request should be skipped if possible.
When the oxlint server gets Thank you again. Let me check this deeply the next day. If you have any feedback to help me, I would appreciate it 🙇 |
|
Hmm, looks like I tested wrong indeed, thank you for the correction. Reaching out to the LSP is also for me fast (median 0.14ms for a dummy small file). I'll keep digging! Regarding the trigger action:
With a config like mine: "editor.codeActionsOnSave": {},
"editor.formatOnSave": truea save is only asking for formatting. The oxlint server does not receive |
|
Aha, I think I found something: A small I might be related to queueing: If I send So I think the trace I posted in the issue can be explained like this:
So the question now is, does this PR fix that |
|
So for oxc, I think 2 things can be done:
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: cbee75dbd5
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
I found the cause! This: caused VS Code to involve the oxlint LSP during save, even though only oxfmt + Biome fix-all were configured. Before this PR, the extension forwarded some of those automatic/unscoped requests to oxlint. On small files that is usually invisible, but with type-aware linting on a large TS file oxlint can already be busy with diagnostics/tsgolint work. Then even a normally cheap code-action request can sit behind that work and make Ctrl+S slow. With the PR: if the save request is not explicitly for oxlint fix-all (source.fixAll / source.fixAll.oxc) or a real user-invoked quick fix, we now drop it before it reaches the oxlint LSP. The integration test covers this through a fake oxfmt, a fake Biome source.fixAll.biome provider, and a fake slow oxlint server. It verifies that oxfmt still formats, Biome still gets its save action, and oxlint receives no code-action request. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 27f95a6b9c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: de3f0b9d10
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5d9c386d0f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
Thank you for the detail research why the code action does take longer then expected. Until now, I would like to keep the PR open, lowering the requests can be better, but I do not want to more bloat the extension for workarounds. PS: Your new tests are not included in CI. |
|
Want to come back to you. I could identify the exact problem with a test setup in oxc-project/oxc#23694. I would like to wait for a release with the fix in oxc-project/oxc#23768. Maybe we do not need to touch the editor side at all🤞 Thank you again for your deep research and pointing out what went wrong. |
Summary
This PR tightens code-action routing so the extension does not ask oxlint for code actions when the request cannot produce an oxc lint fix.
Concretely:
triggerKind = Automatic,only = undefined, no diagnostics)source,source.fixAll,source.fixAll.oxc) are skipped unless save settings enable oxlint throughsource,source.fixAll, orsource.fixAll.oxcsource.fixAll.oxc: "never"opts oxlint out even whensourceorsource.fixAllis enabledsource.fixAllandsource.fixAll.oxc), not provider-specific namespaces likesource.fixAll.biomesource.format.oxccode action stays separate from formatter-on-save and no longer participates in broad source-action scansFor the reported format-only save setup:
stock VS Code should run the formatter provider only for the save. While testing this path, we saw VS Code also issue empty automatic unscoped code-action probes around the editor flow. Those probes are not useful for oxlint because there are no diagnostics to fix, and they can add avoidable LSP traffic while type-aware linting is already busy. The extension now drops those empty probes before they reach the oxlint LSP.
The narrower guard is intentional: if VS Code sends an automatic unscoped request with diagnostics, we still forward it so users keep oxlint quick-fix lightbulbs.
The PR also covers these save-action combinations:
VS Code still asks the Biome provider for its awaited save action, oxfmt still formats the file, and oxlint receives no code-action request.
VS Code can issue the save request as
context.only === source.fixAll; the extension now still consults the save settings for that request and respects the oxlint-specific opt-out before forwarding to oxlint.Testing
sourcesave settings, setting opt-out precedence, and unrelated provider-specific fix-all kinds.source.fixAll.biomeprovider in the integration test to verify that Biome's save action can run without routing any oxlint code action.source.fixAllprovider in the integration test to verify thatsource.fixAll.oxc: "never"prevents oxlint from receiving a save code-action request even when generic fix-all runs.Local verification:
pnpm run fmt:checkpnpm run test:unitpnpm run test:format-save