Skip to content

React Router v7 dev server doesn't work with Supabase #108

Closed
cloudflare/workers-sdk
#8862
@jperasmus

Description

@jperasmus

Here is a minimal reproduction repo of the issue: https://github.com/jperasmus/repro-react-router-7-cloudflare-supabase

Steps I took to create the repro:

  • Installed the Cloudflare template within this repo
  • Installed @supabase/supabase-js
  • Enabled the nodejs_compat flag in wrangler config to allow Node.js streams
  • Simply import "@supabase/supabase-js" in the example home.tsx route module
  • Run the app: npm run dev which starts up fine
  • Open the app in the browser, and it will crash with the following error:
node:internal/fs/promises:638
  return new FileHandle(await PromisePrototypeThen(
                        ^

Error: ENOENT: no such file or directory, open 'node:stream'
    at open (node:internal/fs/promises:638:25)
    at Object.readFile (node:internal/fs/promises:1242:14)
    at extractExportsData (file:///xxx/node_modules/vite/dist/node/chunks/dep-Pj_jxEzN.js:18700:24) {
  errno: -2,
  code: 'ENOENT',
  syscall: 'open',

If you comment out the import "@supabase/supabase-js, the problem goes away.

For my own sanity, here is another repro that uses the same @cloudflare/vite-plugin and the Supabase import added to it. Ie. the only difference is it doesn't run via react-router dev. This runs without any errors (after enabling nodejs_compat of course). This leads me to believe the React Router CLI is doing something to cause the issue since it bootstraps the Vite app.

Further, if I first npm run build and then npm run preview on the repo using React Router, the app works. I believe this is fine since the preview is using vite preview directly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions