workos-node: Cloudflare worker support broken since ~v7.15.0
Hey there! I’m getting these errors on startup when using WorkOS under wrangler 3.67.1 and node v22.4.0:
✘ [ERROR] Could not resolve "crypto"
../../node_modules/@peculiar/webcrypto/build/webcrypto.js:9:21:
9 │ var crypto = require('crypto');
╵ ~~~~~~~~
The package "crypto" wasn't found on the file system but is built into node.
Add "node_compat = true" to your wrangler.toml file and make sure to prefix the module name with "node:" to enable Node.js compatibility.
✘ [ERROR] Could not resolve "process"
../../node_modules/@peculiar/webcrypto/build/webcrypto.js:10:22:
10 │ var process = require('process');
╵ ~~~~~~~~~
The package "process" wasn't found on the file system but is built into node.
Add "node_compat = true" to your wrangler.toml file and make sure to prefix the module name with "node:" to enable Node.js compatibility.
Downgrading to @workos-inc/node version 7.14.0 fixes the problem.
Looking through recent commits, I think the addition of this dependency on iron-session broke things: https://github.com/workos/workos-node/compare/v7.14.0...v7.15.0#diff-7ae45ad102eab3b6d7e7896acd08c427a9b25b346470d7bc6507b6481575d519R40
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 15 (8 by maintainers)
@nkohari Looks like it’s caused by this line.
As a temporary fix, you could provide your WorkOS client ID when instantiating the
WorkOSclient:That being said looking into a permanent fix now.
Sure:
Hi @nkohari and @MTG2000 - thanks for the reports. We’ve just released version 7.19.0, which should fix worker/edge support. We also added an additional test to prevent this sort of issue from slipping through the cracks in the future.
Could you confirm this is working for you?
Sup Nate 😎
We have a PR up that should fix this (and the
Illegal invocationerror). We’ll let you know when it’s released!