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

Error publishing to Cloudflare: "generating random values ... can only be performed while handling a request" #10

Open
aboodman opened this issue May 9, 2023 · 7 comments
Assignees

Comments

@aboodman
Copy link

aboodman commented May 9, 2023

This was reported by a user. Debugging with him what's happening is that replicache-transaction relies on replicache for some helper functions (probably wasn't a great idea). And replicache has some load-time code that calls crypto.randomUUID().

The crypto namespace is implemented by CF workers, but you're not allowed to use it outside of a request, apparently.

Not sure what the right solution is here. I think the user can work around either by undefining crypto, or else dynamically loading the module. But other users of replicache-transaction on cf will hit the same problem.

@aboodman
Copy link
Author

aboodman commented May 9, 2023

@arv wdyt?

@aboodman
Copy link
Author

aboodman commented May 9, 2023

On further investigation, it looks like the load-time call to uuid has been fixed in Replicache 13. Perhaps we should do the same thing on the 12 branch.

@arv
Copy link

arv commented May 9, 2023

It is already in v12

Screenshot 2023-05-09 at 12 21 09

https://github.com/rocicorp/replicache-internal/commit/9982954f251c3a8d43e0e697e22a33bc55ff8eb8

Do you know what versions of replicache and replicache-transaction they had?

@aboodman
Copy link
Author

aboodman commented May 9, 2023 via email

@arv
Copy link

arv commented May 12, 2023

I did some more research here. This is the change that we did on mono to fix this:

https://github.com/rocicorp/mono/commit/8e83d2bcf375ebe89feb77231acde8afb0c91814

and here is the same patch on replicache-internal/v12

https://github.com/rocicorp/replicache-internal/commit/4f1d898baaebb76fc8ed9d29f343b5c96c9ceba6

I hear that you say that we do not call these function in v13 but we call them in v12. I have not been able to find such a place. I put a breakpoint next to the crypto.randomUUID call and that is not hit in startup code (tried in replicache tests and replicache-transactions tests).

What version of replicache-transaction & replicache as the costumer using? Is it possible they imported something from replicache and called it manually?

@arv arv assigned aboodman and unassigned arv May 22, 2023
@aboodman
Copy link
Author

CleanShot_2023-05-08_at_16 57 292x

Shoot I agree, it looks like this was fixed in 12. Attached is the stack I witnessed this in. Perhaps I was using an old version of 12?

@arv
Copy link

arv commented May 23, 2023

If you see it again you can always check the version property of the replicache module.

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

No branches or pull requests

2 participants