-
-
Notifications
You must be signed in to change notification settings - Fork 21
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
Cloudflare worker support #13
Comments
Any news on this? |
From the CF docs: Date.now() returns the time of the last I/O. Why is this not enough? Ofc, the more graular the better, but this should be enough for a good entropy (assuming the second part of the string is long enough). |
@205g0 No news, but I don't currently have access to Cloudflare workers to confirm that ulidx works. Once I can confirm that it functions correctly there, at least from a monotonic standpoint, I'll flag this as being compatible. EDIT: After having a quick look for the ability to run Cloudflare worker scripts locally, I did find this article introducing "Cloudworker". This might be a good addition to the testing setup of ulidx to make sure it runs under such an environment. I'll get around to this soon but would accept a PR for it as well. |
I'm starting to work on this, with tests being first. Seems there are some libraries that allow emulating worker environments.. once that's done and the tests pass I'll release an update. |
This also does not work in Vercel edge functions. The error message being:
This happens in a SvelteKit application |
@hamza1311 FWIW I am using (With the key note that the timestamp does not increase within the same request due to Cloudflare workers' Date.now() restriction - which doesn't matter for my use-cases.)
Your error suggests you appear be using a version prior to v2 - it references Vercel Edge/CF workers requires using the 'browser' import. This is selected automatically for me with ulidx v2 (using webpack+turbopack config provided by Next.JS) according to the exports configured in ulidx's |
FYI @perry-mitchell, Wrangler v3 makes it trivial to run a true worker runtime locally now. It now uses In my experience, this package already seems to work perfectly on Cloudflare Workers. The only change that would make it easier to use would be to update your |
That's awesome to hear! @aaronadamsCA That's great advice - I'll add the worker pointer to the exports shortly and will close this issue then. I'd like to add tests locally using such tools so let's see if that makes it into that release or not. I appreciate all the eyes on this! |
Reopening as I still want to make some final changes before release. |
If anyone has the time to setup tests using wrangler, I think this project would definitely benefit from such a guarantee on stability. |
Thanks so much! I can confirm this works perfectly; after upgrading to v2.1.0, we can now |
Support
ulidx
operating in Cloudflare worker contexts, most likely using the monotonic factory feature as active timestamps aren't available. See #5 for more detail.The text was updated successfully, but these errors were encountered: