Skip to content

Isomorphism breaks due to Websockets when using SSR #155

Closed
@ixxie

Description

@ixxie

Bug report

Describe the bug

When importing createClient into a SvelteKit project, the following error is raised:

5:49:56 PM [vite] Error when evaluating SSR module /node_modules/websocket/lib/browser.js?v=f34fcf64:
Error: Could not determine global this
    at /node_modules/websocket/lib/browser.js?v=f34fcf64:7:28
    at instantiateModule (/home/ixxie/repos/minex/node_modules/vite/dist/node/chunks/dep-66eb515d.js:69030:166)

It seems to come from this block of code in the Websockets package.

To Reproduce

npm init svelte@next
npm install
npm install --save-prod @supabase/supabase-js
sed -i "s/<script>/<script>\n\timport { createClient } from '@supabase\/supabase-js';/" ./src/routes/index.svelte
npm run dev

Expected behavior

Import should work without error

Screenshots

If applicable, add screenshots to help explain your problem.

System information

  • Version of supabase-js: 1.11.2
  • Version of Node.js: 14.15.4

Additional context

This was discovered after resolving #153, after which @kiwicopple recommended I create a new issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingreleased

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions