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

Modify Custom Plugin code cause unexpected 504 #14440

Closed
7 tasks done
childrentime opened this issue Sep 22, 2023 · 9 comments
Closed
7 tasks done

Modify Custom Plugin code cause unexpected 504 #14440

childrentime opened this issue Sep 22, 2023 · 9 comments

Comments

@childrentime
Copy link

Describe the bug

I am writing a custom Vite plugin to handle routing.

The plugin works fine, but when I comment out or add console statements in the load function, a 504 error is displayed on the webpage.
image

image

Reproduction

https://github.com/childrentime/vite-react-test

Steps to reproduce

Use npm run dev to start the app.

Visit http://localhost:5173/a route.

And go ./vitePlugns/pluginRoutes.js file, search FIXME word.

System Info

System:
    OS: macOS 13.3
    CPU: (10) arm64 Apple M1 Pro
    Memory: 89.31 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.18.0 - ~/.nvm/versions/node/v18.18.0/bin/node
    Yarn: 1.22.19 - /opt/homebrew/bin/yarn
    npm: 9.8.1 - ~/.nvm/versions/node/v18.18.0/bin/npm
    pnpm: 8.6.2 - ~/Library/pnpm/pnpm
    Watchman: 2023.09.04.00 - /opt/homebrew/bin/watchman
  Browsers:
    Chrome: 116.0.5845.187
    Safari: 16.4
  npmPackages:
    @vitejs/plugin-react: ^4.0.4 => 4.0.4 
    vite: ^4.4.9 => 4.4.9

Used Package Manager

pnpm

Logs

No response

Validations

@bluwy
Copy link
Member

bluwy commented Sep 26, 2023

I can't reproduce this. It's running fine for me. The server seems to be restarting and perhaps the page fetched too eagerly that the server isn't ready yet? Does this also happen if you press the r shortcut in the Vite dev server to manually restart the server?

@bluwy bluwy added the cannot reproduce The bug cannot be reproduced label Sep 26, 2023
@childrentime
Copy link
Author

@bluwy Did you try commenting out the console statements multiple times and then checking the page? It's possible that the issue may not occur in once change.

@childrentime

This comment was marked as outdated.

@childrentime

This comment was marked as outdated.

@childrentime

This comment was marked as outdated.

@bluwy

This comment was marked as outdated.

@childrentime
Copy link
Author

video

2023-10-08.14.30.46.mov

@bluwy
Copy link
Member

bluwy commented Oct 9, 2023

Thanks. Strangely I can reproduce it now with that exact steps.

@bluwy bluwy removed the cannot reproduce The bug cannot be reproduced label Oct 9, 2023
@patak-dev
Copy link
Member

This is fixed by:

See new docs at: https://main.vitejs.dev/guide/ssr.html#setting-up-the-dev-server

We need to use the new versions of Vite middlewares after a restart:

  app.use((req, res, next) => {
    vite.middlewares.handle(req, res, next)
  })

instead of

  app.use(vite.middlewares)

@github-actions github-actions bot locked and limited conversation to collaborators Nov 30, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants