Coder Social home page Coder Social logo

Comments (31)

kainosnoema avatar kainosnoema commented on June 19, 2024 4

@ematipico here's a simple reproduction showing the issue I'm having (maybe not related?):

Before save (swapped imports to be out of order)
Screenshot 2024-01-16 at 11 56 53β€―PM
After save
Screenshot 2024-01-16 at 11 57 04β€―PM

Settings
Screenshot 2024-01-16 at 11 58 29β€―PM

fwiw I also just tried disabling source.addMissingImports and got the same result, so this seems like a bug isolated to source.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?

from biome.

ematipico avatar ematipico commented on June 19, 2024 4

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.

from biome.

Sec-ant avatar Sec-ant commented on June 19, 2024 4

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.

from biome.

g-pex-aerian avatar g-pex-aerian commented on June 19, 2024 3

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?

from biome.

jpike88 avatar jpike88 commented on June 19, 2024 2

Still a problem on 1.5.3

from biome.

arendjr avatar arendjr commented on June 19, 2024 2

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:

mangled_imports

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.

from biome.

hilja avatar hilja commented on June 19, 2024 1

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.

from biome.

jpike88 avatar jpike88 commented on June 19, 2024

Seems to be problematic in this case too:

import { d } from '@dd';
import { a } from '@a';
import { b } from '@b';

But not in this:

import { d } from 'dd';
import { a } from '@a';
import { b } from '@b';

The @ symbol seems to be the reason here.

from biome.

ematipico avatar ematipico commented on June 19, 2024

Can you share a playground link?

from biome.

jpike88 avatar jpike88 commented on June 19, 2024

I can't repro on playground, just vscode

from biome.

ematipico avatar ematipico commented on June 19, 2024

Then you'll have to share a reproduction. This will help us to identify the issue

from biome.

kainosnoema avatar kainosnoema commented on June 19, 2024

source.organizeImports.biome breaks for me in VSCode constantly. It sometimes eats multiple lines of code and then spits out repeated import lines probably due to competing with source.addMissingImports? I've had to disable source.organizeImports.biome entirely since I just can't get it to work consistently without breaking code.

I don't have a working reproduction offhand since it seems to have to do with combination of quickfix.biome, source.organizeImports.biome, and source.addMissingImports, but will try to replicate it next time I see it.

from biome.

ematipico avatar ematipico commented on June 19, 2024

Sorry @kainosnoema , this isn't a reproduction.

We need to be able to reproduce the issue. A repository would be great.

Without that , we can't help.

from biome.

arendjr avatar arendjr commented on June 19, 2024

I’ll try enabling source.organizeImports.biome in my setup, see if I run into it.

from biome.

jansedlon avatar jansedlon commented on June 19, 2024

Yeah, same issue here. It randomly happens as well. Reloading VSCode works. Sometimes the imports completely disappears, sometimes it completely changes
image

from biome.

arendjr avatar arendjr commented on June 19, 2024

I wonder to what extent this issue and #1584 are related. I'm getting the impression both situations may be caused by having too many daemons running.

As far as I see, I also only see Mac users in these threads. So if there's a non-Mac user experiencing this, please raise your voice, since it might help us figure out in which direction to look.

from biome.

jansedlon avatar jansedlon commented on June 19, 2024

Hasn't happened to me since 1.5.2-dev and 1.5.3 πŸ€”

from biome.

jpike88 avatar jpike88 commented on June 19, 2024

I'm not sure how or why... but disabling reenabling plugin seemed to work afterwards... I'll keep you posted

from biome.

ematipico avatar ematipico commented on June 19, 2024

Thank you all for confirming.

For anyone coming here , to apply the fix you must restart your VSCode after updating to Biome 1.5.3. There was an issue in the LSP.

from biome.

arendjr avatar arendjr commented on June 19, 2024

Today I heard reports from several co-workers that seem to be running into this issue still, all on 1.5.3. Unfortunately, I haven't been able to witness it myself, but I did notice just now that I had 4 Biome formatter entries in VS Code, which was also one of the things my co-workers witnessed.

So while #1590 seems to have fixed #1584 (the issue that two Biome formatter entries appear in VS Code right away), I think there is still a lurking issue that causes additional entries to be registered over time. And my assumption here is that once there are multiple entries, they can still conflict and trigger this behavior.

I'm afraid I still have no additional information what might be the root cause however :(

from biome.

arendjr avatar arendjr commented on June 19, 2024

Okay, and now that it happened once, if I use Undo to revert to how the imports were before they got mangled, then hit Save (I have Organize Imports enabled on Save) it mangles it again.

Update: One more piece of information: If I invoke Organize Imports explicitly, I get to choose between 5 entries. I think one is VS Code's native Organize Imports, while the other 4 are marked as Biome:

organize_import_entries

I can select any of those 5 entries, and the imports get organized as expected. So the functionality itself is fine. But I hit Save, and it mangles again, presumably because multiple get invoked at the same time.

Update: If I reorder imports in another file and Save, it also mangles there. So somehow I've gotten into a state now where it will always mangle if I Save while there are imports that need sorting. Saving files where the imports are already sorted is still fine.

from biome.

ematipico avatar ematipico commented on June 19, 2024

Is it possible that you enabled the rule https://biomejs.dev/linter/rules/use-import-type/ ?

from biome.

arendjr avatar arendjr commented on June 19, 2024

It shouldn't be, no...

from biome.

hilja avatar hilja commented on June 19, 2024

I've got very similar issues, when organizing imports on save. I’m using subpath imports, basically import aliases that start with #. Also I have noUnusedImports on, might make the issue worse.

Here it removes a wrong import:

Screen.Recording.2024-03-12.at.17.07.03.mov

Here React is not removed properly:

Screen.Recording.2024-03-13.at.09.25.28.mov

Here React is added twice and the last import it messed up:

Screen.Recording.2024-03-13.at.10.12.57.mov

This issue #1015 suggested using config like below, it did help at first but has since gotten worse, maybe after updating to 1.6.2, not sure.

{
  "editor.codeActionsOnSave": {
    "source.fixAll": "explicit",
    "quickfix.biome": "explicit",
    "source.organizeImports.biome": "explicit"
  }
}

Any tips for the VSCode config?

Would an umbrella issue be helpful? There seems to be quite a bit of report relating to this.

from biome.

ematipico avatar ematipico commented on June 19, 2024

Also I have noUnusedImports on, might make the issue worse.

I noticed that some of the bugs reported are caused by this very rule.

from biome.

Sec-ant avatar Sec-ant commented on June 19, 2024

Can anyone confirm whether the failing cases in this issue can still be reproducible in the latest version (v1.6.4)?

from biome.

jansedlon avatar jansedlon commented on June 19, 2024

Just messed up my imports πŸ˜… Had 2 biome instances on version 1.6.4
image

from biome.

jpike88 avatar jpike88 commented on June 19, 2024

I just want to say you guys are the best, eslint is happily far in the rear view mirror and it's hard to imagine things were any different. Just need that pesky no-hanging-promises and this will be literally perfection in both how it's written and its application.

from biome.

hilja avatar hilja commented on June 19, 2024

First import sorting issue since updating to 1.6.4. It might have something to do with the automatic fixing of the double quotes. If I cmd+z the last fix and then save again it's fixed.

In general it’s been working so much better! Thanks for fixing it.

Screen.Recording.2024-04-06.at.08.48.29.mov

from biome.

toteto avatar toteto commented on June 19, 2024

After initially enabling the "source.organizeImports.biome": "explicit" I was getting shuffled and random imports. They were overlapping with one another, and there were also duplicates.

Doing "undo" and formatting again, worked OK.

What fixed it for now was restarting VS Code as some of the previous comments have mentioned.

from biome.

valeneiko avatar valeneiko commented on June 19, 2024

Looks like this issue is a bit broader and applies to lint rule fixes too: biomejs/biome-vscode#241
I can consistenlty reproduce the issue with the linked example, so hopefully this will help debug it.
And I only have one instance of Biome LSP running.

from biome.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.