biomejs / biome

A toolchain for web projects, aimed to provide functionalities to maintain them. Biome offers formatter and linter, usable via CLI and LSP.

Home Page:https://biomejs.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

πŸ› <WasmError>

ianzone opened this issue Β· comments

Environment information

CLI:
  Version:                      1.8.0
  Color support:                true

Platform:
  CPU Architecture:             x86_64
  OS:                           linux

Environment:
  BIOME_LOG_DIR:                unset
  NO_COLOR:                     unset
  TERM:                         "xterm-256color"
  JS_RUNTIME_VERSION:           "v20.14.0"
  JS_RUNTIME_NAME:              "node"
  NODE_PACKAGE_MANAGER:         "pnpm/9.2.0"

Biome Configuration:
  Status:                       Loaded successfully
  Formatter disabled:           false
  Linter disabled:              false
  Organize imports disabled:    false
  VCS disabled:                 false

Workspace:
  Open Documents:               0

What happened?

Reproduce:

  1. clone https://github.com/ianzone/vite-plugin-biomejs/tree/wasm-bug
  2. pnpm i
  3. pnpm nx test e2e
  4. open the dev server link
  5. see error

Output:

[vite] Internal server error:
  Plugin: vite-plugin-biomejs
  File: /home/ian/vite-plugin-biomejs/packages/e2e/src/main.tsx
      at WasmError.fromError (/home/ian/vite-plugin-biomejs/node_modules/.pnpm/@biomejs+js-api@0.6.0_@biomejs+wasm-nodejs@1.8.0/node_modules/@biomejs/js-api/dist/wasm.js:83:16)
      at wrapError (/home/ian/vite-plugin-biomejs/node_modules/.pnpm/@biomejs+js-api@0.6.0_@biomejs+wasm-nodejs@1.8.0/node_modules/@biomejs/js-api/dist/wasm.js:92:22)
      at Biome.tryCatchWrapper (/home/ian/vite-plugin-biomejs/node_modules/.pnpm/@biomejs+js-api@0.6.0_@biomejs+wasm-nodejs@1.8.0/node_modules/@biomejs/js-api/dist/index.js:63:40)
      at Biome.withFile (/home/ian/vite-plugin-biomejs/node_modules/.pnpm/@biomejs+js-api@0.6.0_@biomejs+wasm-nodejs@1.8.0/node_modules/@biomejs/js-api/dist/index.js:67:21)
      at Biome.formatContent (/home/ian/vite-plugin-biomejs/node_modules/.pnpm/@biomejs+js-api@0.6.0_@biomejs+wasm-nodejs@1.8.0/node_modules/@biomejs/js-api/dist/index.js:93:21)
      at TransformContext.transform (file:///home/ian/vite-plugin-biomejs/packages/vite-plugin-biomejs/dist/index.js:23:33)
      at Object.transform (file:///home/ian/vite-plugin-biomejs/node_modules/.pnpm/vite@5.2.13_@types+node@20.14.2/node_modules/vite/dist/node/chunks/dep-DEPSZ3SS.js:52318:62)
      at async loadAndTransform (file:///home/ian/vite-plugin-biomejs/node_modules/.pnpm/vite@5.2.13_@types+node@20.14.2/node_modules/vite/dist/node/chunks/dep-DEPSZ3SS.js:55073:29)
      at async viteTransformMiddleware (file:///home/ian/vite-plugin-biomejs/node_modules/.pnpm/vite@5.2.13_@types+node@20.14.2/node_modules/vite/dist/node/chunks/dep-DEPSZ3SS.js:64920:32)

Expected result

no error thrown

Code of Conduct

  • I agree to follow Biome's Code of Conduct

We don't maintain that plugin, I suggest filing an issue in their repository

it actually happened before #2744

Sorry for the inconvenience.

The JavaScript APIs aren't well maintained and they are in alpha for a reason. I suggest you to check how we consume the WASM target inside the website repository -> playground

For example, we changed things very recently and now must register a project before setting up the configuration.

It's possible that these changes aren't reflected in the JavaScript APIs, so a PR might be needed to fix your bug

I'm seeing this in my project as well

/home/runner/work/openapi-code-generator/openapi-code-generator/node_modules/@biomejs/js-api/dist/wasm.js:83
        return new WasmError(e);
               ^

WasmError
    at WasmError.fromError (/home/runner/work/openapi-code-generator/openapi-code-generator/node_modules/@biomejs/js-api/dist/wasm.js:83:16)
    at wrapError (/home/runner/work/openapi-code-generator/openapi-code-generator/node_modules/@biomejs/js-api/dist/wasm.js:92:22)
    at Biome.tryCatchWrapper (/home/runner/work/openapi-code-generator/openapi-code-generator/node_modules/@biomejs/js-api/dist/index.js:63:40)
    at Biome.withFile (/home/runner/work/openapi-code-generator/openapi-code-generator/node_modules/@biomejs/js-api/dist/index.js:67:21)
    at Biome.formatContent (/home/runner/work/openapi-code-generator/openapi-code-generator/node_modules/@biomejs/js-api/dist/index.js:93:21)
    at writeOutput (/home/runner/work/openapi-code-generator/openapi-code-generator/scripts/generate-ajv-validator.js:33:27)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  stackTrace: Error: Error: missing field `only`
      at module.exports.__wbg_new_28c511d9baebfa89 (/home/runner/work/openapi-code-generator/openapi-code-generator/node_modules/@biomejs/wasm-nodejs/biome_wasm.js:922:17)
      at wasm://wasm/02c92192:wasm-function[10295]:0x8f26e6
      at wasm://wasm/02c92192:wasm-function[6050]:0x81a082
      at wasm://wasm/02c92192:wasm-function[6635]:0x836fb0
      at Workspace.pullDiagnostics (/home/runner/work/openapi-code-generator/openapi-code-generator/node_modules/@biomejs/wasm-nodejs/biome_wasm.js:549:18)
      at /home/runner/work/openapi-code-generator/openapi-code-generator/node_modules/@biomejs/js-api/dist/index.js:95:52
      at /home/runner/work/openapi-code-generator/openapi-code-generator/node_modules/@biomejs/js-api/dist/index.js:77:24
      at Biome.tryCatchWrapper (/home/runner/work/openapi-code-generator/openapi-code-generator/node_modules/@biomejs/js-api/dist/index.js:60:20)
      at Biome.withFile (/home/runner/work/openapi-code-generator/openapi-code-generator/node_modules/@biomejs/js-api/dist/index.js:67:21)
      at Biome.formatContent (/home/runner/work/openapi-code-generator/openapi-code-generator/node_modules/@biomejs/js-api/dist/index.js:93:21)
}

Which has a pretty vanilla use of the bindings https://github.com/mnahkies/openapi-code-generator/blob/main/packages/openapi-code-generator/src/typescript/common/typescript-formatter.biome.ts#L6-L46

(as an aside, I've not had much success getting the web WASM distribution to work, but not sure if that's me or the package)

Suspect the @biomejs/js-api needs updating

I'm not sure about the error in OP's post. But the error in #3126 (comment) is probably due to the reason that we didn't publish a new @biome/js-api package when the pull diagnostics API is changed (with the skip and only option)