yiwen-ai / xid-ts

xid is a globally unique id generator thought for the web. A Typescript port of https://github.com/rs/xid.
MIT License
24 stars 2 forks source link

any idea if this will work on cloudflare workers? #3

Open newbeelearn opened 1 year ago

newbeelearn commented 1 year ago

cloudflare workers are not exactly compatible with nodejs they need special compatibilty flag to emulate nodejs. For instance process may not be available in runtime. Would this library work on it?

zensh commented 1 year ago

The problem is "Uncaught Error: Some functionality, such as asynchronous I/O, timeouts, and generating random values, can only be performed while handling a request." on crypto.getRandomValues.

zensh commented 1 year ago

Xid relies on global state and may need to be implemented with durable objects.

https://developers.cloudflare.com/workers/configuration/durable-objects/

newbeelearn commented 1 year ago

i see thanks for the confirmation.