-
Notifications
You must be signed in to change notification settings - Fork 65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uncaught ReferenceError: Buffer is not defined in Partykit (Cloudflare Worker) #1003
Comments
Quick fix: Put |
Appreciate the note about the workaround, hopefully that'll hold over anyone who might be running into this until we can get out a proper fix. For a fix, we should either use a browser compatible API that also works with Node and doesn't sacrifice performance (might be hard...) or use our existing "adapter" pattern to chose either a Node-like or Browser-like adapter like we do for crypto. |
The workaround doesn't seem to work when using @edgedb/generate 🤦♂️ This works better: instead of importing Buffer, check Buffer from globalThis:
Thanks for this @scotttrinh! |
Thanks for the investigation there! That's definitely an easy fix, so good to know that works for the Cloudflare context. Will update. |
Describe the bug
I am trying to use EdgeDB in Partykit, which runs on Cloudflare Workers. When starting the Partykit dev server locally, it throws the error:
Uncaught ReferenceError: Buffer is not defined
I am not sure how far the local dev server goes to simulate a Cloudflare Worker environment, but CF Workers do support Buffer: https://developers.cloudflare.com/workers/runtime-apis/nodejs
It has to be imported, it can't be used as a global.
The error happens immediately when the dev server is started.
Reproduction
Any use of the edgedb-js client.
Expected behavior
I do not expect an error.
Versions (please complete the following information):
2.0
): 5.2+1e07d042.0
): EdgeDB CLI 5.1.0+8ff9f85edgedb-js
version (e.g.0.20.10
;): 1.5.5Additional context
I am running the Partykit dev server with Bun, but I also tried with Node and it had the same result.
The text was updated successfully, but these errors were encountered: