Uuid from workflow sdk vs via activity

I see that the @temporalio/workflow package provides a uuid4 method.

What’s the difference between using this to generate a uuid directly in your workflow vs calling out to an activity that generates a uuid v4 from a standard uuid library?

Hello @Shawn_Jones

uuid4 is a utility that temporal provides to make the uuid4 generation safe from the workflow’s determinism point of view.

Generating it within an activity will record the result in the event history, which is also safe since the activity won’t be executed again and the value taken on replay will be the one recorded in the event history.

Let me know if it helps.


1 Like

From the docstring:

Generate an RFC compliant V4 uuid. Uses the workflow’s deterministic PRNG making it safe for use within a workflow. This function is cryptographically insecure. See the stackoverflow discussion.