webcontainer-core icon indicating copy to clipboard operation
webcontainer-core copied to clipboard

Vite dev server not working on blitz first open

Open msfstef opened this issue 1 year ago • 0 comments

Describe the bug

Loading a Vite + React project from GitHub and running a dev server fails to load - the dev server starts, but any loads either fail with failures to resolve files or the dev server stops with an esbuild error. Building and then serving the app works, as well as retrying the dev server a few times.

Error 1 (Vite)

Internal server error: Failed to resolve import "4dPuKpREKQ2XB790C00000032" from "node_modules/.vite/deps/chunk-ONSCSK7J.js?v=f5403d87". Does the file exist?

Error 2 (esbuild)

Error: The service was stopped
    at eval (/home/projects/gqainwkxq.github/node_modules/esbuild/lib/main.js:1101:28)
    at responseCallbacks.<computed> (/home/projects/gqainwkxq.github/node_modules/esbuild/lib/main.js:694:9)
    at Socket.afterClose (/home/projects/gqainwkxq.github/node_modules/esbuild/lib/main.js:684:28)
    at EventEmitter.emit (node:events:42:9318)
    at endReadableNT (node:internal/streams/readable:105:15152)
    at _0x398360 (https://gqainwkxqgithub-ru2k.w-staticblitz.com/blitz.810981ba.js:352:154306)
    at <anonymous> (https://gqainwkxqgithub-ru2k.w-staticblitz.com/blitz.810981ba.js:352:154055)

Link to the blitz that caused the error

https://stackblitz.com/github/electric-sql/electric/tree/msfstef/prepare-recipes-for-demo/examples/recipes?embed=1&startScript=demo&file=src%2Flog_viewer%2FLogViewer.tsx&initialpath=log-viewer&title=Log%20Viewer

Steps to reproduce

  1. Open the linked blitz
  2. Let the npm run demo command run, which should successfully start the server and initiate a browser load
  3. Wait for either a Vite file resolution error or an esbuild error that temrinates the server

The errors appear inconsistent and are only happening for the dev server - building and serving the app seems to work, as well as manually retrying the dev server, but the first load seem to consistently fail.

Expected behavior

Should load the app on the browser without issues upon opening the blitz (no extra waiting, building and serving, or retying needed)

Parity with Local

Screenshots

Screenshot 2024-03-21 at 15 09 59 Screenshot 2024-03-21 at 15 01 56

Platform

  • macOS Sonoma 14.3.1
  • Chrome
  • Version 122.0.6261.129 (Official Build) (arm64)

Additional context

No response

msfstef avatar Mar 21 '24 13:03 msfstef