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
I just spent 3 hours fixing an XMLHttpRequest is not defined error that occurred when running the serverless driver on edge runtime (CF Pages in this case).
The documentation recommends the following setup to work in a serverless environment:
Thanks @LilaRest. Can you point me to which documentation recommended that? It's only necessary to provide a WebSocket library on Node and other WebSocket-less platforms.
It also should not be necessary to set fetch as the fetchFunction (that will be the default), and you only need poolQueryViaFetch to speed up one-shot queries or if WebSockets are not available and you still want to use the Pool object.
Update on this, I've been confused because some functions of the Clerk server library were producing the same error, once this solved, the only way I've managed to make the Neon serverless driver work on Cloudflare Pages is by not setting any neonConfig.* parameter.
My guess is that the ws package is not compatible with v8 runtime. I wonder what Websocket client the serverless driver is using if none is explicitely defined though.
The README could mention in a brief way that: "If you're trying to run this driver on edge runtimes (e.g., Cloudflare Pages, Vercel Edge Functions) you MUST NOT set the neonConfig.webSocketConstructor to ws"
Hey there!
I just spent 3 hours fixing an
XMLHttpRequest is not defined
error that occurred when running the serverless driver on edge runtime (CF Pages in this case).The documentation recommends the following setup to work in a serverless environment:
However, if you want to run your code on edge, you'll need to apply this config instead:
@jawj, I'm creating this issue for reference, but maybe it could even be documented in the README? What do you think?
Enjoy your day guys,
And thanks for this awesome lib!
The text was updated successfully, but these errors were encountered: