biome-vscode: šŸ› Quickfix slows down saving files in VSCode

VS Code version

1.90.0-insiders

Extension version

2.2.3

Biome version

1.7.3

Operating system

  • Windows
  • macOS
  • Linux

Description

When this config is enabled in vscode settings

    "quickfix.biome": "explicit"

it slows down saving files in vscode. But not always šŸ˜…. When i type something and immediately hit Cmd + Save, there’s like a second delay before the file is saved.

Interestingly enough, if i type something and wait a second and hit save, the file is saved immediately.

Steps to reproduce

  1. Enable "quickfix.biome": "explicit",
  2. Hit Cmd + Save immediately after typing something

Expected behavior

It should save immediately

Does this issue occur when using the CLI directly?

Not sure / Not applicable

Logs

Logs contain actions that happened when i entered ā€œEnterā€ and immediately save

[Trace - 8:36:03 AM] Sending notification 'textDocument/didChange'.
Params: {
    "textDocument": {
        "uri": "file:///Users/jansedlon/Work/Flixy/flixy/packages/prisma/index.ts",
        "version": 174
    },
    "contentChanges": [
        {
            "range": {
                "start": {
                    "line": 22,
                    "character": 20
                },
                "end": {
                    "line": 22,
                    "character": 20
                }
            },
            "rangeLength": 0,
            "text": "\n  "
        }
    ]
}


[Trace - 8:36:03 AM] Received notification 'textDocument/publishDiagnostics'.
Params: {
    "uri": "file:///Users/jansedlon/Work/Flixy/flixy/packages/prisma/index.ts",
    "diagnostics": [],
    "version": 174
}


[Trace - 8:36:03 AM] Sending request 'textDocument/codeAction - (409)'.
Params: {
    "textDocument": {
        "uri": "file:///Users/jansedlon/Work/Flixy/flixy/packages/prisma/index.ts"
    },
    "range": {
        "start": {
            "line": 0,
            "character": 0
        },
        "end": {
            "line": 95,
            "character": 0
        }
    },
    "context": {
        "diagnostics": [],
        "only": [
            "source.fixAll"
        ],
        "triggerKind": 2
    }
}


[Trace - 8:36:03 AM] Received response 'textDocument/codeAction - (409)' in 1ms.
Result: []


[Trace - 8:36:03 AM] Sending request 'textDocument/codeAction - (410)'.
Params: {
    "textDocument": {
        "uri": "file:///Users/jansedlon/Work/Flixy/flixy/packages/prisma/index.ts"
    },
    "range": {
        "start": {
            "line": 0,
            "character": 0
        },
        "end": {
            "line": 95,
            "character": 0
        }
    },
    "context": {
        "diagnostics": [],
        "only": [
            "source.organizeImports"
        ],
        "triggerKind": 2
    }
}


[Trace - 8:36:03 AM] Received response 'textDocument/codeAction - (410)' in 0ms.
Result: []


[Trace - 8:36:03 AM] Sending request 'textDocument/codeAction - (411)'.
Params: {
    "textDocument": {
        "uri": "file:///Users/jansedlon/Work/Flixy/flixy/packages/prisma/index.ts"
    },
    "range": {
        "start": {
            "line": 0,
            "character": 0
        },
        "end": {
            "line": 95,
            "character": 0
        }
    },
    "context": {
        "diagnostics": [],
        "only": [
            "quickfix.biome"
        ],
        "triggerKind": 2
    }
}


[Trace - 8:36:03 AM] Received response 'textDocument/codeAction - (411)' in 0ms.
Result: []


[Trace - 8:36:03 AM] Sending request 'textDocument/codeAction - (412)'.
Params: {
    "textDocument": {
        "uri": "file:///Users/jansedlon/Work/Flixy/flixy/packages/prisma/index.ts"
    },
    "range": {
        "start": {
            "line": 23,
            "character": 2
        },
        "end": {
            "line": 23,
            "character": 2
        }
    },
    "context": {
        "diagnostics": [],
        "triggerKind": 2
    }
}


[Trace - 8:36:03 AM] Received response 'textDocument/codeAction - (412)' in 1ms.
Result: []


[Trace - 8:36:04 AM] Sending request 'textDocument/formatting - (413)'.
Params: {
    "textDocument": {
        "uri": "file:///Users/jansedlon/Work/Flixy/flixy/packages/prisma/index.ts"
    },
    "options": {
        "tabSize": 2,
        "insertSpaces": true
    }
}


[Trace - 8:36:04 AM] Received response 'textDocument/formatting - (413)' in 2ms.
Result: [
    {
        "range": {
            "start": {
                "line": 0,
                "character": 0
            },
            "end": {
                "line": 96,
                "character": 0
            }
        },
        "newText": "import { remember } from \"@epic-web/remember\";\nimport { handlePrismaLogging, logger } from \"@flixydev/logger\";\nimport { Prisma, PrismaClient, type Subscription } from \"@prisma/client\";\nimport { type Result, ResultAsync, errAsync } from \"neverthrow\";\n\nexport const prisma = remember(\"prisma\", () => {\n  const client = new PrismaClient({\n    log: [\n      {\n        level: \"query\",\n        emit: \"event\",\n      },\n    ],\n  });\n\n  handlePrismaLogging({\n    db: client,\n    logger: logger,\n    logLevels: [\"query\"],\n    slowQueryThresholdMs: 20,\n  });\n\n  client.$connect();\n\n  return client.$extends({\n    result: {\n      user: {\n        stripeActivated: {\n          needs: {\n            stripeConnectAccountId: true,\n            stripeDetailsSubmitted: true,\n          },\n          compute(data) {\n            return (\n              !!data.stripeConnectAccountId && !!data.stripeDetailsSubmitted\n            );\n          },\n        },\n      },\n    },\n    model: {\n      $allModels: {\n        async exists<T>(\n          this: T,\n          where: Prisma.Args<T, \"findFirst\">[\"where\"],\n        ): Promise<boolean> {\n          const context = Prisma.getExtensionContext(this);\n          // biome-ignore lint/suspicious/noExplicitAny: <explanation>\n          const result = await (context as any).findFirst({ where });\n\n          return result !== null;\n        },\n      },\n      user: {\n        async findActiveSubscription(userId: string) {\n          return prisma.subscription.findFirst({\n            where: {\n              userId,\n              status: {\n                in: [\"active\", \"trialing\"],\n              },\n              deletedAt: null,\n            },\n          });\n        },\n        async cancelActiveSubscription(\n          userId: string,\n        ): Promise<Result<Subscription, Error>> {\n          const activeSubscription = await this.findActiveSubscription(userId);\n\n          if (!activeSubscription) {\n            return errAsync(new Error(\"No active subscription found\"));\n          }\n\n          const update = await ResultAsync.fromPromise(\n            prisma.subscription.update({\n              where: {\n                id: activeSubscription.id,\n              },\n              data: {\n                cancelledAt: new Date(),\n              },\n            }),\n            (e) => e as Error,\n          );\n\n          return update;\n        },\n      },\n    },\n  });\n});\n\nexport * from \"@prisma/client\";\n"
    }
]


[Trace - 8:36:04 AM] Sending notification 'textDocument/didChange'.
Params: {
    "textDocument": {
        "uri": "file:///Users/jansedlon/Work/Flixy/flixy/packages/prisma/index.ts",
        "version": 175
    },
    "contentChanges": [
        {
            "range": {
                "start": {
                    "line": 23,
                    "character": 0
                },
                "end": {
                    "line": 24,
                    "character": 0
                }
            },
            "rangeLength": 3,
            "text": ""
        }
    ]
}


[Trace - 8:36:04 AM] Received notification 'textDocument/publishDiagnostics'.
Params: {
    "uri": "file:///Users/jansedlon/Work/Flixy/flixy/packages/prisma/index.ts",
    "diagnostics": [],
    "version": 175
}


[Trace - 8:36:04 AM] Sending notification 'textDocument/didSave'.
Params: {
    "textDocument": {
        "uri": "file:///Users/jansedlon/Work/Flixy/flixy/packages/prisma/index.ts"
    }
}


[Trace - 8:36:04 AM] Sending request 'textDocument/codeAction - (414)'.
Params: {
    "textDocument": {
        "uri": "file:///Users/jansedlon/Work/Flixy/flixy/packages/prisma/index.ts"
    },
    "range": {
        "start": {
            "line": 23,
            "character": 0
        },
        "end": {
            "line": 23,
            "character": 0
        }
    },
    "context": {
        "diagnostics": [],
        "triggerKind": 2
    }
}


[Trace - 8:36:04 AM] Received response 'textDocument/codeAction - (414)' in 1ms.
Result: []

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 7
  • Comments: 37 (7 by maintainers)

Most upvoted comments

Really appreciate the investigation @mizdra, I’ll be following along!

I’m experiencing the same thing in:

Software Versión
VS Code 1.93.1
Extension 2.3.0
Biome 1.9.1
Operating System Windows

I set this setting in my vscode and apparently it works perfect, no lag:

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

Another thing I noticed is that the "quickfix.biome": "explicit" lag only affects JS, JSX, TS, TSX files. No lag in CSS files.

I have this same problem with the quickfix. It appears to me that it is waiting for the typescript check to complete before running. The longer the type checking takes the longer the delay appears to be before it saves the file. Perhaps there could be a way to move the quickfixing before the type checking, maybe into the formatting step, instead?

I have investigated this issue further. It appears to be a compatibility issue between typescript-language-features and the Biome extension.

However, I think I need to know about the editor.codeActionsOnSave spec to determine a solution to this problem. Therefore, I have written a question to the VS Code team. You can find it at

I believe I’m experiencing the same thing. Something feels slow, but I have to mention that biome is very new for me still

@nhedger i am experiencing the same issue in .vue files, quick save is very slow (3 second delay) when i have those settings

  "editor.codeActionsOnSave": {
    "quickfix.biome": "explicit"
  },

in extension host output i also see those messages

image

disabling the vue extension or removing those settings makes saving very fast again

There appears to be a decent repro in this issue: https://github.com/biomejs/biome/issues/4680

Link: https://github.com/OliverJAsh/biome-vscode-quickfix-import-issue/compare/1.7.3

I’ve also experienced this in Zod. You can pull down this branch to repro: https://github.com/colinhacks/zod/tree/slow-quickfix

$ gh repo clone colinhacks/zod
$ cd zod
$ git checkout slow-quickfix
$ yarn 
$ code .

I’ve introduced a formatting issue at the top of src/index.ts. Saving that file in VS Code should trigger the slow quickfixing. Interestingly I get faster fix-on-save with "source.fixAll": "always". Does that behave in a meaningfully different way than "quickfix.biome": "always"?

We just ran into the issue after following the docs recommendation. I’ve put up a PR to update the docs here: https://github.com/biomejs/website/pull/1736

source.fixAll.biome seems to work on my end. I think the documentation needs updating.

I get the reluctance to ship a new major version as a maintainer. All I can say as an interested potential user is that I’d love to see this problem get solved sooner. (We have a large Typescript mono-repo that we unsuccessfully tried to migrate to Biome earlier this year, and it was blocked only by the VSCode extension performance, as the CLI itself is very fast.)

I did some digging in the docs. The LSP protocol doesn’t say anything about the distinction between a quickfix and a fixall, except that they are different code actions.

However, the VSCode Typescript docs suggest that ā€œfixallā€ is the action intended to be used on save because it will compute all the fixes in one round.

By contrast, a quickfix is mentioned as an individual suggestion designed to be handled one at a time, and it seems to be listed as an alternative to a ā€œrefactorā€ code action.

Users should start adding the *.biome suffix to the code actions e.g. source.fixAll.biome. This should instruct the clients to only run code actions that belong to Biome. Not adding the suffix e.g. source.fixAll would mean telling the clients to run ALL the code actions of all the language servers that listen to that filter.

If the client (VSCode, Zed, etc.) sends the correct payload, Biome LSP should apply the changes.

I have investigated this problem. I hope it is useful.

reproduction repository: https://github.com/mizdra/quickfix-biome-slow

Reproduction Test: Part 1

Apparently, the problem reproduces without any 3rd-party extensions. Surprisingly, it reproduces without biome-vscode.

The workspace used for reproduction is as follows:

.vscode/settings.json:

{
    "editor.codeActionsOnSave": {
        "quickfix.biome": "explicit"
      }
}

index.ts:

function fn(){
    console.log('hello');
}

https://github.com/user-attachments/assets/56415cd5-d02e-4fd8-acc2-a5dcffb04932

This suggests that the problem is caused by something other than the biome-vscode.

Reproduction Test: Part 2

The problem does not seem to reproduce with .css.

The workspace used for reproduction is as follows:

.vscode/settings.json:

{
    "editor.codeActionsOnSave": {
        "quickfix.biome": "explicit"
      }
}

index.css:

.foo {
    background: black;
}

https://github.com/user-attachments/assets/6719fd2a-a1d5-4591-ae13-10834259eca3

This suggests that the problem is .ts specific.

Reproduction Test: Part 3

If you disable VS Code’s built-in js/ts extension, the problem does not reproduce.

How to disable VS Code’s built-in js/ts extension:

  1. Select Side Bar > ... > Show Running Extensions
    • image
  2. Right-click TypeScript and JavaScript Language Features and select Disable
    • image
  3. Restart VS Code

https://github.com/user-attachments/assets/a8ebed83-dc5e-4ade-9292-bcda18af25d9


From these tests, I believe the problem is caused by VS Code, VS Code’s built-in js/ts extension (TypeScript and JavaScript Language Features), or tsserver.

I don’t think biome-vscode has anything to do with this problem.