workos / workos-node

Official Node SDK for interacting with the WorkOS API
https://workos.com/docs/sdk/node
MIT License
119 stars 29 forks source link

Make emitWarning safe for workers #1135

Closed PaulAsjes closed 2 weeks ago

PaulAsjes commented 2 weeks ago

Description

If you currently try to build a next project that uses workos-node you get the following error:

./node_modules/@workos-inc/node/lib/workos.js
A Node.js API is used (process.emitWarning at line: 178) which is not supported in the Edge Runtime.

This is because despite the fact that we have an if/else statement checking for whether process exists, the Next build step just sees a call to process.emitWarning and spits out that error. This moves the definition of emitWarning to the worker index.ts to prevent that error.

Documentation

Does this require changes to the WorkOS Docs? E.g. the API 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.