You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using @supabase/supabase-js, a user is able to provide custom fetch by providing a global.fetch option. However, with @supabase/node-fetch statically imported, a Cannot read property 'bind' of undefined error may throw at runtime.
TypeError: Cannot read property 'bind' of undefined
at path/to/node_modules/@supabase/node-fetch/browser.js
The error is thrown when the runtime environment does not have native fetch on globalObject at all.
Chore
Describe the chore
Request update the static import of
@supabase/node-fetch
insrc/lib/fetch.ts
:supabase-js/src/lib/fetch.ts
Lines 2 to 17 in 4c7f571
supabase-js/src/lib/fetch.ts
Lines 18 to 24 in 4c7f571
Use dynamic
import('@supabase/node-fetch')
to avoid possibleCannot read property 'bind' of undefined
error.Additional context
Related to this issue supabase/postgrest-js#574.
Using
@supabase/supabase-js
, a user is able to provide custom fetch by providing aglobal.fetch
option. However, with@supabase/node-fetch
statically imported, aCannot read property 'bind' of undefined
error may throw at runtime.The error is thrown when the runtime environment does not have native
fetch
onglobalObject
at all.https://github.com/supabase/node-fetch/blob/bd8f50a4ae647e56cda296b8301d7dff01d4a87b/browser.js#L18.
In some other
@supabase/
packages like@supabase/auth-js
, the fetch is resolved using aresolveFetch
function:https://github.com/supabase/auth-js/blob/8af88b6f4e41872b73e84c40f71793dab6c62126/src/lib/helpers.ts#L93-L104.
This way, the
node-fetch
import is safe. We could also implement this fornodeFetch
andHeaders
imported here.The text was updated successfully, but these errors were encountered: