Closed piccinnigius closed 11 months ago
@piccinnigius which version of realtime-js are you on when using supabase-js? this should be fixed in realtime-js v2.9.1. try upgrading supabase-js in your react native app.
@w3b6x9 thanks for replying.
I'm using latest supabasejs that comes with realtime v2.9.1 :/
@piccinnigius which react native version are you on?
@w3b6x9 I've been on 0.71.14 and to check if on newer versions works I've upgraded to 0.73.1
@piccinnigius that's odd b/c it's working fine for me. here are my setup steps:
npx react-native@latest init TestProject
(v0.73.1)npm install @supabase/supabase-js
(v2.39.2) - confirmed that it's on realtime-js
v0.29.1npm install react-native-url-polyfill
and imported at the top of index.js - looks like this is a necessity b/c supabase-js is using URL
did you have the same steps? can you share exactly your setup and the output you're seeing?
@w3b6x9 i can confirm that usually works. I think that part of the problem is related to using webpack on React Native.
In second hand we can refeer to ws readme that says:
Note: This module does not work in the browser. The client in the docs is a reference to a back end with the role of a client in the WebSocket communication. Browser clients must use the native WebSocket object. To make the same code work seamlessly on Node.js and the browser, you can use one of the many wrappers available on npm, like isomorphic-ws.
The real question is: why if in React Native Websocket is available and NATIVE_WEBSOCKET_AVAILABLE is true this section messing up resulting in using ws package?
Anyway this is the output:
Thanks in advance
@piccinnigius have you tried polyfill-ing all the modules listed in the error message?
@w3b6x9 yes, this results in maximum call stack exceeded error
@w3b6x9 I've fixed by marking ws as external in webpack configuration. Idk if something needs to be done on realtime-js side.
it works also by doing eval on the import but I think that it's a bit anti-pattern
Thanks for your help.
@piccinnigius nice, glad that marking it external got it working.
The real question is: why if in React Native Websocket is available and NATIVE_WEBSOCKET_AVAILABLE is true this section messing up resulting in using ws package?
i'm still wondering this that you pointed out. i'll look into this and see if i can come up with anything.
Bug report
Describe the bug
After "move from websocket to ws and support native browser WebSocket API" (#263) cannot build anymore in React Native (Webpack). In particular ws module cannot find some libraries url,stream, etc. Adding Polyfills causes max call stack errors.
To Reproduce
Steps to reproduce the behavior, please provide code snippets or a repository:
Expected behavior
Replacement of websocket to ws must not be a breaking change.
System information
Additional context
Same codebase, same build steps works as usual using @supabase/supabase-js 2.36.0 - realtime 2.8.4