Skip to content
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

Incompatibility with Cloudflare Workers #964

Closed
Pelps12 opened this issue Feb 18, 2024 · 2 comments · Fixed by #965
Closed

Incompatibility with Cloudflare Workers #964

Pelps12 opened this issue Feb 18, 2024 · 2 comments · Fixed by #965

Comments

@Pelps12
Copy link

Pelps12 commented Feb 18, 2024

Although buffer is globally defined in a node environment, in an edge environment like Cloudflare Workers, Buffer has to be imported as "node:buffer". Frameworks like SvelteKit handle the conversion of "buffer" to "node:buffer" internally Link. However, in constructEvent, because Buffer is assumed to be globally defined. Screenshot 2024-02-17 225517

When deployed to Cloudflare, my SvelteKit application's webhook errors out with "Buffer not defined"
Screenshot 2024-02-17 224746

@benoitgrelard
Copy link
Contributor

benoitgrelard commented Feb 19, 2024

Hey @Pelps12, you are 100% right, that's my bad for letting this one through.
Will have a PR up with a fix in a few minutes.

benoitgrelard added a commit that referenced this issue Feb 19, 2024
benoitgrelard added a commit that referenced this issue Feb 19, 2024
## Description

Fixes #964

There was a leftover usage of Node's `Buffer` API.
I have converted it to use the web platform's `TextEncoder` APIs
instead.

I wonder if there's an ESLint plugin that could be used to lint for
usages of APIs incompatible with cloudflare workers/edge runtime as it
seems easy to let something through without thoroughly testing every
single API call. A quick google search didn't bring much up so far.

## Documentation

Does this require changes to the WorkOS Docs? E.g. the [API
Reference](https://workos.com/docs/reference) or code snippets need
updates.

```
[ ] Yes
```

If yes, link a related docs PR and add a docs maintainer as a reviewer.
Their approval is required.
@benoitgrelard
Copy link
Contributor

Hey @Pelps12, v6.0.1 has now been published, it contains a few fixes including one for this issue.

https://github.com/workos/workos-node/releases/tag/v6.0.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

2 participants