Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Invalid command: on-resolve" after update from 4.1.4 #14043

Closed
7 tasks done
jeffw-wherethebitsroam opened this issue Aug 8, 2023 · 13 comments
Closed
7 tasks done

"Invalid command: on-resolve" after update from 4.1.4 #14043

jeffw-wherethebitsroam opened this issue Aug 8, 2023 · 13 comments
Labels
bug: upstream Bug in a dependency of Vite p3-downstream-blocker Blocking the downstream ecosystem to work properly (priority)

Comments

@jeffw-wherethebitsroam
Copy link

Describe the bug

I have a project that was working successfully with vite 4.1.4, but after updating (I have tried 4.2.2 and now 4.4.9) I fails to run the development server, with hundreds of errors like:

✘ [ERROR] Invalid command: on-resolve [plugin JavaScript plugins]

    node_modules/vite/node_modules/esbuild/lib/main.js:734:12:
      734 │       throw new Error(`Invalid command: ` + request.command);
          ╵             ^

    at handleRequest (/Users/jeffwilliams/dev/Intelecy/frontend/node_modules/vite/node_modules/esbuild/lib/main.js:734:13)
    at handleIncomingPacket (/Users/jeffwilliams/dev/Intelecy/frontend/node_modules/vite/node_modules/esbuild/lib/main.js:755:7)
    at Socket.readFromStdout (/Users/jeffwilliams/dev/Intelecy/frontend/node_modules/vite/node_modules/esbuild/lib/main.js:679:7)
    at Socket.emit (node:events:511:28)
    at addChunk (node:internal/streams/readable:332:12)
    at readableAddChunk (node:internal/streams/readable:305:9)
    at Readable.push (node:internal/streams/readable:242:10)
    at Pipe.onStreamRead (node:internal/stream_base_commons:190:23)

  The plugin "JavaScript plugins" was triggered by this import

    node_modules/react-syntax-highlighter/dist/esm/async-languages/prism.js:1386:4:
      1386 │     "refractor/lang/zig.js");
           ╵     ~~~~~~~~~~~~~~~~~~~~~~~

vite build still works successfully.

This looks similar to the issues mentioned in storybookjs/storybook#22253, but occur when running the development server, not storybook.

The error appears to occur after server reload:

1:40:06 pm [vite] changed tsconfig file detected: /Users/jeffwilliams/vite-bug/tsconfig.json - Clearing cache and forcing full-reload to ensure TypeScript is compiled with updated config values
.
2023-08-08T11:40:06.937Z vite:hmr [config change] vite.config.ts
1:40:06 pm [vite] vite.config.ts changed, restarting server...
...
1:40:07 pm [vite] Internal server error: The server is being restarted or closed. Request is outdated
      at throwClosedServerError (file:///Users/jeffwilliams/vite-bug/node_modules/vite/dist/node/chunks/dep-df561101.js:43799:17)
      at transformRequest (file:///Users/jeffwilliams/vite-bug/node_modules/vite/dist/node/chunks/dep-df561101.js:54782:9)
      at Object.transformRequest (file:///Users/jeffwilliams/vite-bug/node_modules/vite/dist/node/chunks/dep-df561101.js:64995:20)
      at preTransformRequest (file:///Users/jeffwilliams/vite-bug/node_modules/vite/dist/node/chunks/dep-df561101.js:64631:12)
      at processNodeUrl (file:///Users/jeffwilliams/vite-bug/node_modules/vite/dist/node/chunks/dep-df561101.js:64458:13)
      at file:///Users/jeffwilliams/vite-bug/node_modules/vite/dist/node/chunks/dep-df561101.js:64540:17
      at traverseNodes (file:///Users/jeffwilliams/vite-bug/node_modules/vite/dist/node/chunks/dep-df561101.js:37401:5)
      at file:///Users/jeffwilliams/vite-bug/node_modules/vite/dist/node/chunks/dep-df561101.js:37405:48
      at Array.forEach (<anonymous>)
      at traverseNodes (file:///Users/jeffwilliams/vite-bug/node_modules/vite/dist/node/chunks/dep-df561101.js:37405:25)
      at file:///Users/jeffwilliams/vite-bug/node_modules/vite/dist/node/chunks/dep-df561101.js:37405:48
      at Array.forEach (<anonymous>)
      at traverseNodes (file:///Users/jeffwilliams/vite-bug/node_modules/vite/dist/node/chunks/dep-df561101.js:37405:25)
      at file:///Users/jeffwilliams/vite-bug/node_modules/vite/dist/node/chunks/dep-df561101.js:37405:48
      at Array.forEach (<anonymous>)
      at traverseNodes (file:///Users/jeffwilliams/vite-bug/node_modules/vite/dist/node/chunks/dep-df561101.js:37405:25)
      at traverseHtml (file:///Users/jeffwilliams/vite-bug/node_modules/vite/dist/node/chunks/dep-df561101.js:37418:5)
      at async devHtmlHook (file:///Users/jeffwilliams/vite-bug/node_modules/vite/dist/node/chunks/dep-df561101.js:64532:5)
      at async applyHtmlTransforms (file:///Users/jeffwilliams/vite-bug/node_modules/vite/dist/node/chunks/dep-df561101.js:38015:21)
      at async viteIndexHtmlMiddleware (file:///Users/jeffwilliams/vite-bug/node_modules/vite/dist/node/chunks/dep-df561101.js:64613:28)
...
✘ [ERROR] The build was canceled
...
✘ [ERROR] Invalid command: on-resolve [plugin JavaScript plugins]

    node_modules/esbuild/lib/main.js:734:12:
      734 │       throw new Error(`Invalid command: ` + request.command);
          ╵             ^

    at handleRequest (/Users/jeffwilliams/vite-bug/node_modules/esbuild/lib/main.js:734:13)
    at handleIncomingPacket (/Users/jeffwilliams/vite-bug/node_modules/esbuild/lib/main.js:755:7)
    at Socket.readFromStdout (/Users/jeffwilliams/vite-bug/node_modules/esbuild/lib/main.js:679:7)
    at Socket.emit (node:events:511:28)
    at addChunk (node:internal/streams/readable:332:12)
    at readableAddChunk (node:internal/streams/readable:305:9)
    at Readable.push (node:internal/streams/readable:242:10)
    at Pipe.onStreamRead (node:internal/stream_base_commons:190:23)

  The plugin "JavaScript plugins" was triggered by this import

    node_modules/react-virtualized/dist/es/ColumnSizer/ColumnSizer.js:3:39:
      3 │ ...ctorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
        ╵                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

After these errors, the dev server seems to go into a restart loop.

Reproduction

https://github.com/wherethebitsroam/vite-bug

Steps to reproduce

Run yarn install, yarn vite -d, make a request to localhost:3000

Note that this repo is an edited version of https://github.com/streamlit/streamlit/tree/1.11.0/frontend, which seems to be causing the problem when referenced in our project.

System Info

System:
    OS: macOS 13.5
    CPU: (4) x64 Intel(R) Core(TM) i5-7267U CPU @ 3.10GHz
    Memory: 989.44 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.2.0 - /usr/local/bin/node
    Yarn: 3.3.0 - /usr/local/bin/yarn
    npm: 9.6.6 - /usr/local/bin/npm
  Browsers:
    Chrome: 115.0.5790.170
    Firefox: 115.0.3
    Safari: 16.6
  npmPackages:
    @vitejs/plugin-react: ^4.0.4 => 4.0.4
    vite: ^4.4.9 => 4.4.9

Used Package Manager

yarn

Logs

https://github.com/wherethebitsroam/vite-bug/blob/main/vite.log

This log was created by the command:
yarn vite -d |& tee vite.log

I had to kill vite to get it to stop restarting.

Validations

@alecthomas
Copy link

We're also seeing this, though it eventually succeeds after throwing out many MB of errors.

@timseverien
Copy link

Seeing similar errors, but I’m neither using yarn or storybook. Although it does eventually produce a bundle, Netlify recognises it as an error and refuses to publish. Below is a list of my dependencies. Hopefully that’ll help rule out some interfering modules (or whatever the issue may be).

"@astrojs/mdx": "^0.19.7",
"@astrojs/sitemap": "^2.0.1",
"@astrojs/svelte": "^3.1.0",
"assert-never": "^1.2.1",
"astro": "^2.10.7",
"axios": "^1.4.0",
"css-select": "^5.1.0",
"date-fns": "^2.30.0",
"he": "^1.2.0",
"htmlparser2": "^9.0.0",
"lodash": "^4.17.21",
"markdown-it": "^13.0.1",
"modern-css-reset": "^1.4.0",
"sanitize-html": "^2.11.0",
"slugify": "^1.6.6",
"svelte": "^4.2.0",
"vite-plugin-dts": "^3.5.2",
"vite": "^4.4.9",
"vitest": "^0.34.1"

@bluwy
Copy link
Member

bluwy commented Aug 14, 2023

I can't access the repro, is it set to private? I'm not really sure how the error is caused, it seems to be coming from esbuild's default "Javascript plugin" Go plugin that processes all of the JS plugins for esbuild.

@Hideman85
Copy link

Same error here, works with 4.1.4, not working with any of the next version. It works fine with Linux and windows devs but not on macos 😕

@iarmankhan
Copy link

Same error here, with 4.3.2 and 4.4.x not working with both of these versions.

Works fine with 4.1.4 only.

Here's my system configuration:

System:
    Model: Macbook Pro M2 Max 32GB
    OS: macOS 13.4.1
    CPU: M2 Max
    Memory: 989.44 MB / 16.00 GB
    Shell: zsh 5.9 (x86_64-apple-darwin22.0)
 Binaries:
    Node: 18.17.1
    Yarn: 3.3.0
    npm: 9.6.7

@zhouLion
Copy link

Dependency esbuild version ^0.18.10 is automatically upgraded to 0.18.12, and this version of on-resolve will report an error.

My solution is override vite dep in package.json:

  "overrides": {
    "vite": {
      "esbuild": "0.18.10"
    }
  }

@iarmankhan
Copy link

@zhouLion I tried the same but it didn't work. The same error is there. I put the provided code in my package.json, removed node_modules and install the dependencies again.

@sapphi-red
Copy link
Member

I tested all (possible) reproductions linked to storybookjs/storybook#22253. But I wasn't able to reproduce any of them.

I noticed that all reports that includes a system info uses Mac. I guess this only happens on Mac.
(#14043 (comment), #14043 (comment), storybookjs/storybook#22253 (comment), storybookjs/storybook#22253 (comment), storybookjs/storybook#22253 (comment), storybookjs/storybook#23101 (comment), storybookjs/storybook#22808 (comment), storybookjs/storybook#22808 (comment))

@jeffw-wherethebitsroam
Copy link
Author

I can't access the repro, is it set to private? I'm not really sure how the error is caused, it seems to be coming from esbuild's default "Javascript plugin" Go plugin that processes all of the JS plugins for esbuild.

Yes, sorry about that - the repo was private. Now public.

@jeffw-wherethebitsroam
Copy link
Author

I tested using pnpm and received the same issue.
I tried the override from #14043 (comment) but did see any change.

I testing the same repo on Linux and did not see the issue. So it could well be a Mac only thing as @sapphi-red said. Config of the linux system for reference:

  System:
    OS: Linux 5.15 Ubuntu 22.04.3 LTS 22.04.3 LTS (Jammy Jellyfish)
    CPU: (2) x64 Intel(R) Xeon(R) Platinum 8272CL CPU @ 2.60GHz
    Memory: 6.98 GB / 7.70 GB
    Container: Yes
    Shell: 5.1.16 - /bin/bash
  Binaries:
    Node: 18.17.1 - ~/.nvm/versions/node/v18.17.1/bin/node
    Yarn: 3.3.0 - ~/.nvm/versions/node/v18.17.1/bin/yarn
    npm: 9.6.7 - ~/.nvm/versions/node/v18.17.1/bin/npm
    pnpm: 8.6.12 - ~/.nvm/versions/node/v18.17.1/bin/pnpm
  npmPackages:
    @vitejs/plugin-react: ^4.0.4 => 4.0.4
    vite: ^4.4.9 => 4.4.9

@yoyo930021
Copy link
Contributor

yoyo930021 commented Aug 18, 2023

Temporary Solutions:
You need to patch fsevents package to your project from this fsevents/fsevents@63709df

The pnpm example:

pnpm patch fsevents
# edit fsevents.js from output folder
pnpm patch-commit <output-folder>

ref: paulmillr/chokidar#1286 (comment)

@jeffw-wherethebitsroam
Copy link
Author

@yoyo930021 I actually ended up on that same chokidar issue and saw you had linked to it :)

I can confirm that the issue I was seeing was the storm of 'unlink' events from chokidar for every file in my directory, causing vite to restart continually. Patching fsevents as described in the link resolved the issue for me.

@sapphi-red sapphi-red added bug: upstream Bug in a dependency of Vite p3-downstream-blocker Blocking the downstream ecosystem to work properly (priority) and removed pending triage labels Aug 19, 2023
@sapphi-red
Copy link
Member

sapphi-red commented Aug 22, 2023

Closing as a new fsevents version containing the patch was released (v2.3.3).

@github-actions github-actions bot locked and limited conversation to collaborators Sep 6, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug: upstream Bug in a dependency of Vite p3-downstream-blocker Blocking the downstream ecosystem to work properly (priority)
Projects
None yet
Development

No branches or pull requests

9 participants