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: open
- Created 6 months ago
- Reactions: 5
- Comments: 29 (15 by maintainers)
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.
@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.addMissingImports
and 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?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.
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?
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.
Still a problem on 1.5.3
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.