supabase-js icon indicating copy to clipboard operation
supabase-js copied to clipboard

chore(lib/fetch): dynamic import `@supabase/node-fetch`

Open liyachun01 opened this issue 1 year ago • 3 comments

Dynamic import('@supabase/node-fetch') in lib/fetch to avoid possible Cannot read property 'bind' of undefined error.

Closes #1303

liyachun01 avatar Nov 09 '24 13:11 liyachun01

Similar updates are made to @supabase/postgrest-js, see https://github.com/supabase/postgrest-js/pull/576

liyachun01 avatar Nov 09 '24 14:11 liyachun01

Hi @soedirgo, please kindly look at this PR, thanks~

liyachun01 avatar Nov 10 '24 07:11 liyachun01

In my opinion this is a very good improvement, thanks for the work @liyachun01! This will probably also solve problems when using supabase-js in an Angular project with SSR enabled.

I hope that this PR can be reviewed and merged in the near future. 🤞

jsprds avatar Dec 10 '24 19:12 jsprds

Hi @liyachun01 ! Thank you so much for your contribution and for taking the time to address issue #1303!

I will not be merging this PR now, as the async approach introduces a performance regression for all browser requests (every request now requires an unnecessary await even when Headers is immediately available).

That being said, once we officially drop support for Node 18 (October 31st) as we recently announced, and remove the @supabase/node-fetch dependency on November 1st, this issue will be resolved entirely without any performance impact.

I know this may not be the immediate solution you were hoping for, but I want to avoid introducing performance costs that affect all users when we have a clean, permanent fix coming in just a few months. I do hope you understand, and thank you very very much for your patience. I am also going to refer you to this PR, where I replied almost the same thing. I do hope my rationale makes sense for you.

If you think there's another solution that would keep everyone happy until November, please let me know! :D

Again, thank you very much for your patience and for contributing to Supabase!

mandarini avatar Jul 25 '25 13:07 mandarini