biome: š Import sorting breaks with a particular import line when saving in VSCode
Environment information
CLI:
Version: 1.5.1
Color support: true
Platform:
CPU Architecture: aarch64
OS: macos
Environment:
BIOME_LOG_DIR: unset
NO_COLOR: unset
TERM: "xterm-256color"
JS_RUNTIME_VERSION: "v18.17.1"
JS_RUNTIME_NAME: "node"
NODE_PACKAGE_MANAGER: "npm/9.6.7"
Biome Configuration:
Status: Loaded successfully
Formatter disabled: true
Linter disabled: false
Organize imports disabled: false
VCS disabled: true
Workspace:
Open Documents: 0
Biome VSCode extension version v2.1.1
What happened?
With organizeImports enabled and this config in workspace:
"editor.codeActionsOnSave": {
"quickfix.biome": "explicit",
"source.organizeImports.biome": "explicit"
},
just add this particular import line to any script that has a bunch of existing imports.
import {MaxInteger32Value } from '@shared/MaxInteger32Value';
Minimal reproducible case below:
import {MaxInteger32Value } from '@shared/MaxInteger32Value';
import { a } from '@a';
import { b } from '@b';
Something about this particular string causes havoc by duplicating it, and replacing existing import lines below it. See screenshot
This only happens in VSCode, I canāt reproduce it on the playground.
Expected result
Code of Conduct
- I agree to follow Biomeās Code of Conduct
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 40
- Comments: 56 (22 by maintainers)
Iām going to share this again and close the issue.
The issue is fixed in the pre-release version of VSCode. The bug was caused by how the extension was connected to the server, which caused spawning multiple processes and connections of the Biome Daemon. This becomes evident every time Biome is updated. Hence, on save, multiple instructions were received by the client and caused this.
The pre-release fixed this. I donāt know when we will ship it as stable.
Instructions to fix the issue onwards:
biomeprocessesbiome explain --daemon-logsto identify the cache folder used by biome in your OS (more here https://biomejs.dev/guides/editors/create-a-extension/#daemon-logs)@ematipico hereās a simple reproduction showing the issue Iām having (maybe not related?):
Before save (swapped imports to be out of order)
After save

Settings
fwiw I also just tried disabling
source.addMissingImportsand got the same result, so this seems like a bug isolated tosource.organizeImports.biome. Update: interestingly restarting VSCode or resetting the extension host seems to fix things temporarily, so the example above works again until it starts breaking and then I can reproduce it consistently until I restart again. Maybe thereās some sort of corrupted internal state of either VSCode or the extension?Is this still only in the pre-release? itās been awhile
+1. Just started trying biome in my project. organizeImports breaks imports
Update: Reload Window command in VS Code solved the issue
I have also been experiencing this issue. It seems to be because there is many Biome agents running and happens if I have left my Mac on overnight. If I hover over a Biome warning or error I can see the error repeated, sometimes 20 times.
Closing VSCode completely does fix the issue and Biome suggestions are no longer duplicated.
So I would suggest the issue is with Biome seemingly restarting without killing the previous process for some reason?
This has gotten significantly worse for me in the last week or two. Even restarting cursor doesnāt reliably stop it, Iām on the latest prerelease of the extension.
Use the preview release of the VSCode extension, that should fix it.
Yeah I donāt think the issue caused by multiple instances are fixed. And thereāre still failing cases that Iām aware of even there is only one instance. This is a complex issue, but weāll fix it step by step.
And just like that, I finally witnessed the imports being messed up with my own eyes too! Iād been keeping the session with 4 Biome entries open, and it further reinforces my suspicion of the mangled imports and duplicate formatter entries being related: The mangled imports I witnessed had one of the imports being repeated 4 times:
One thing of note though, this didnāt happen to me on Save or by manually using Organize Imports. It happened when I renamed a symbol in one file and VS Code applied the refactoring to update that symbol in another file. Maybe that somehow triggered all four formatters to kick in, causing the renamed symbol to appear 4 times.
We just published a nightly with a possible fix: https://github.com/biomejs/biome/releases/tag/cli/v1.5.2-nightly.91c7730
It would be great if someone can try it, and let us know.
Still a problem on 1.5.3
Just a note, the command is now
biome explain daemon-logsHello, just passing by to say it happens all the time, on each new import to be sorted. It have been happening since the day I started using Biome.
Before sort:
After sort:
Expected:
I have
Biome 1.9.4and my VSCode extension is2.3.0.Here is an extract of my
project settings.jsonI just installed the preview version
2024.12.22126of the vscode extension. The bug seems to be fixed on the example given in this comment.Congrats on fixing the bug!
This issue still happens to me with
biome@1.9.4and the latestvscodeextensions.It seems that
noUnusedImportsmake it even worst indeed. It would be nice to increase the priority of this issue if possible š Thanks for you work on this library, itās really good !i run into garbled imports anytime i try to save where i have a regular import and a type import in the same import line
@sshmaxime Did you read my comment? https://github.com/biomejs/biome/issues/1570#issuecomment-2456703582
If you do install the preview release, remember to kill all processes of
biome, itās possible there are few of them hanging.I hit this issue quite often as well. I had to remove the āsource.organizeImports.biomeā: āexplicitā setting because biome would constantly break my imports.
Just did little refactoring, removing and shuffling around code and so far it worked flawlessly š But that was only about 15 minutes of coding, Iāll report if anything else pops up.
I noticed that some of the bugs reported are caused by this very rule.