remix-run / remix

Build Better Websites. Create modern, resilient user experiences with web fundamentals.
https://remix.run
MIT License
30.02k stars 2.53k forks source link

Error loops when clientLoader crashes after setting environment variables in root.tsx #9423

Open mkizka opened 6 months ago

mkizka commented 6 months ago

Reproduction

  1. Access https://stackblitz.com/edit/remix-run-remix-t17vmh?file=README.md
  2. Open Preview in new tab
  3. Open Chrome DevTools

The only files edited are app/route/_index.tsx and app/root.tsx. I followed https://remix.run/docs/en/main/guides/envvars to set the environment variables.

image

System Info

$ npx envinfo --system --npmPackages '{vite,@remix-run/*}' --binaries --browsers
Need to install the following packages:
envinfo@7.13.0
Ok to proceed? (y) y

  System:
    OS: Linux 5.15 Ubuntu 22.04.3 LTS 22.04.3 LTS (Jammy Jellyfish)
    CPU: (12) x64 12th Gen Intel(R) Core(TM) i5-12400
    Memory: 13.46 GB / 15.62 GB
    Container: Yes
    Shell: 3.7.0 - /usr/bin/fish
  Binaries:
    Node: 20.13.0 - ~/.local/share/mise/installs/node/lts/bin/node
    npm: 10.5.2 - ~/.local/share/mise/installs/node/lts/bin/npm
    pnpm: 8.15.7 - ~/.local/share/mise/installs/node/lts/bin/pnpm
  Browsers:
    Chrome: 121.0.6167.85
  npmPackages:
    @remix-run/dev: ^2.9.2 => 2.9.2 
    @remix-run/node: ^2.9.2 => 2.9.2 
    @remix-run/react: ^2.9.2 => 2.9.2 
    @remix-run/serve: ^2.9.2 => 2.9.2 
    vite: ^5.1.0 => 5.2.11

Used Package Manager

pnpm

Expected Behavior

Error does not loop, and is displayed on the screen.

Actual Behavior

Error loops and nothing is displayed on the screen.

mkizka commented 6 months ago

I found a workaround. Regarding the environment variables, you can revert to root.tsx and use the VITE_ prefix and import.meta.env. https://vitejs.dev/guide/env-and-mode.html