Fixing Temporal non-determinism errors

A runbook for diagnosing Temporal non-determinism errors, finding the workflow code change behind them, and choosing a safe fix with patching, versioning or reset.

On this page

Why a Temporal non-determinism error stops workflows after a deploy

A deploy has left workflow tasks failing with non-determinism errors, and running workflows have stopped making progress. Temporal does not stop a workflow because its code is wrong in general. It stops a workflow task because the code now in the worker would issue a different sequence of commands than the one already recorded in that workflow's event history. Temporal rebuilds workflow state by replaying the history against the current workflow code, and when a timer, activity, child workflow, signal handler or other command appears in a different order, or is missing, the replay no longer matches. The task fails with a WorkflowTaskFailed event, and the workflow waits until a worker runs code that matches the history again.

Teams need this runbook after a deploy that changed workflow code, not during first development. Before any workflow has run on a given code path, there is no recorded history to conflict with, so the same change is usually harmless. The risk appears when executions that started on the old code are still open and the new worker picks them up. Long-running workflows, schedules and workflows waiting on signals are the usual cases, because they can stay open across several deploys. Dependency upgrades, changed default options and reordered branches can cause the same failure even when the change looked small in review.

Confirm the specifics in the documentation for your own SDK, since the exact command types that are checked, the failure messages and the replay behavior differ between language SDKs and versions. Before you change anything, list which workflow types have open executions, which worker build is running them, and when the first failing task appeared. That timeline tells you whether one deploy caused the failures and whether the fix is a code correction, a versioning change or a reset. Stalled workflows also hold resources and may block business processes, so decide early who owns the incident and whether affected workflows should be paused while the fix is prepared.

Which code changes cause non-determinism in running workflows

Temporal rebuilds workflow state by replaying recorded history against the current code. Any change that makes the code issue commands in a different order, with different identities or different values than the recorded history causes a mismatch. The cards below cover the change types that most often trigger this in running workflows, and what to check before deploying each one.

Reordering or removing activities

Moving an activity call above or below another call, or deleting one, changes the order of commands the workflow expects during replay. When a running workflow replays and reaches a point where the recorded ActivityTaskScheduled event no longer matches the code's next command, the worker raises a non-determinism error. Workflows that have not yet reached the changed point usually replay cleanly, so failures often appear only in long-running executions. Check the code path against the event history of an affected run before deploying.

Self-hosted deployment docs

Adding, removing or moving timers

A timer is a command in workflow history. Inserting a new sleep, deleting an existing one, or changing the order of timers relative to other commands makes replay expect a different sequence than was recorded. Changing a timer duration alone can also matter when the duration is used to decide later branching. Running workflows that are waiting on the old timer are the most exposed, because their next replay reaches the changed command. Review timers in the same way as activities, and confirm which open executions are sleeping on them.

Changing signal and child workflow handling

Signal handlers and child workflow starts are recorded as events and commands. Adding a new signal wait, moving a wait to a different point, or starting a child workflow earlier or later alters the expected event sequence during replay. Child workflows add a further risk, because changing their workflow type name or input shape can also break the parent's replay. Running parents that are blocked on a signal or waiting for a child to finish are typically the affected workflows. Check both the parent and child code paths together.

Changing branch conditions on values

An if statement that depends on a value from an activity result, a signal payload or a prior decision is deterministic only if the same value is produced on replay. Changing the condition, or the threshold it compares against, can send replay down a different branch that issues a different command than the one recorded. This risk is easy to miss in reviews because the change looks like a business rule update. Workflows that already passed the branch are usually safe, while those currently inside it are at risk.

Calling time, randomness or I/O directly

Reading the wall clock, generating random values, or calling an external API from inside workflow code produces different results on each replay. A workflow that calls a clock or random function directly will not reproduce the same decisions when history is replayed, which Temporal reports as non-determinism. Use the SDK's deterministic time and random helpers, and move all external I/O into activities. This problem usually appears in new code that was not reviewed against the SDK's determinism rules, and it can affect any running workflow that reaches the line.

Renaming commands or changing their types

Commands are matched during replay by type and by identity, such as an activity type name, a timer, or a child workflow type. Renaming an activity or child workflow type, or changing an activity's input type in a way that alters how the call is recorded, can make replay fail to find the event it expects. Renaming a workflow type is a separate concern, since it affects which executions a new worker can pick up. Confirm names, types and task queues with a search of running executions before the rename ships.

How to read a WorkflowTaskFailed event and find the offending change

This sequence takes a non-determinism alert from a list of failing workflows to the exact command that diverged and the commit that introduced it. The output is a confirmed cause and a fix decision: patch, version or reset.

  1. Identify the failing workflows and their pattern

    Start in the Web UI or with a visibility query that filters for running workflows with a failing workflow task, then list the workflow IDs, workflow types and start times. The on-call engineer or service owner does this. Done means you have a list of affected IDs and a count, and you can say whether the failures cluster on one workflow type or span several. Confirm the visibility store can answer this query, since the query depends on the visibility backend your deployment uses.

  2. Check the worker build and deploy timing

    Compare when the failures started with your deployment history for the worker service that polls the affected task queue. Record the worker build version or image tag that reported the failure, and whether any older worker builds are still running on the same queue. Many workflows failing with the same error after one release points to a code change deployed to workers. Scattered failures across unrelated builds and dates point to data or a single stuck execution instead. Done means you have a deploy timeline and a clear yes or no on whether one build is involved.

  3. Open the event history and find the failed task

    Open one affected workflow's event history and locate the WorkflowTaskFailed event. Read its cause and the failure message, which names the workflow task that could not be replayed, and note the event ID and the event that preceded it. The engineer reading history does this. Done means you have the event ID, the failure message text and the last successfully completed workflow task, which bounds the part of history the new code must have replayed.

  4. Compare the recorded commands with the new code's commands

    Walk the history up to the failed task and list the commands the original code recorded, such as activity scheduled, timer started, child workflow started or signal sent, in order. Then run the same input through the code at the failing build, for example by replaying the history locally with the SDK replayer, and capture the command the new code produced at the same point. Done means you can state the mismatch in one sentence, such as an activity that was expected but a timer was produced, or a branch that changed order. If you cannot reproduce it locally, record the inputs and the mismatch from the failure message for the next step.

  5. Map the divergence to the source change

    Take the mismatched command and find the code that produces it in version control. Diff the failing build's commit against the last build that replayed this workflow cleanly, focusing on the function that decides the command: conditionals, loops, activity options, renamed activities or changed order of awaits. Non-determinism usually comes from a change to the workflow definition itself, not from activities. Done means you have a commit or pull request and a line range that explains the mismatch, and a reviewer agrees the diff changes workflow decisions.

  6. Confirm the scope of affected executions

    Run a visibility query that matches the workflow type and the failing build's start time to count every open execution that started before the change and is still running. Check whether any of them have already passed the divergence point. Done means you have a count and a list of open executions, split into those that will hit the same mismatch and those that will not. Confirm with the SDK documentation which Temporal operations are affected by your SDK version, since behavior varies.

  7. Choose the fix path and record the decision

    Decide between three paths: revert the change and redeploy, add a patch or version marker so new code takes a different branch only for executions started after the change, or reset affected workflows to a point before the divergence once the fix is deployed. The workflow owner and the platform on-call approve the choice in writing. Done means the decision names the commit, the affected workflow count, the chosen path and the person who approved it, and the next steps link to the patching, versioning and reset runbooks.

Patching, versioning or reset: choosing the fix by situation

When the non-deterministic change has never reached production, the cleanest fix is usually to revert or rewrite the code before any run records a history that depends on it. Workflows that were started only on a local or staging environment can often be discarded or restarted, so no existing history needs to replay against the corrected code. Confirm first that no workflow in the target namespace was started with the faulty build, because a single execution is enough to make the change matter.

  • Revert before patching: If the change is still on a branch or in an unreleased build, remove it and rebuild rather than adding a guard around it.
  • Check for started executions: List workflows by type and build date in the target namespace before assuming the change never ran.
  • Restart test workflows: Terminate or let finish any test executions that recorded the faulty code path, then start fresh ones on the corrected build.
  • Keep the replay test: Add a replay test that loads a captured history from the faulty version so the same mistake is caught in future changes.
  • Skip version guards: A guard adds code that must be maintained for the life of the workflow type, which is unnecessary when no history exists.

Before promoting the build, confirm that the workflow type has no open executions from the faulty version in any environment that will be promoted. Ask your Temporal engineers to confirm the replay test runs in your CI pipeline.

Which fix fits which non-determinism error

This table compares rollback, a patch or version guard, a new workflow type or task queue, and a reset of affected workflows. Read each row as one option, checking what it changes, what keeps running on the old code, and the main risk before choosing.

Fix optionWhat it changesWhat it leaves runningMain riskWhen it fits
Roll back the codeRedeploys the previous worker build so replay matches the recorded history againExecutions started on the new build keep their history, and any new commands they recorded remainOther changes shipped in the same release are lost too, and workers may fail again if a rollback leaves mixed buildsThe change was a regression, nothing else needs to ship, and the failing tasks can be replayed on the old code
Patch or version guard in workflow codeAdds a branch that keeps old histories on the original path and sends new executions down the changed pathRunning executions continue on the old path until they finish, so the guard must stay until they drainGuards are easy to forget or remove early, and nested or repeated guards become hard to readRunning workflows must survive the change and you can keep both code paths in one deployment
New workflow type or task queueRoutes new executions to a separately named workflow type or a new task queue with the changed codeExisting executions stay on the original type or queue and the original worker codeTwo code versions must be run and monitored until the old executions close, and callers must switch routingThe change is large, existing executions are few or can finish naturally, or you want a clean cutover
Reset affected workflowsRewinds stuck executions to an earlier event so they re-run the changed code from that pointWork done after the reset point is re-executed, so activities may run againActivities after the reset point can repeat side effects, and resetting many executions needs careful selectionExecutions are stuck on a non-determinism error, the bad code is already fixed, and repeated activities are safe or idempotent

Decision path from failing task to fix

The path starts when a workflow task fails with a non-determinism error after a worker deploy. The first check is whether the failure is limited to one deploy, since that decides whether rolling back the worker is enough. If running workflows must continue on new code, the team adds a patch or version guard. If new executions should use the changed logic, they start under a new workflow version. A targeted reset is the last branch, used only when history must be resumed from an earlier point. Every branch ends at a replay of the affected histories, and traffic is restored only after that replay passes.

Decision path from a non-determinism failure to a verified fix.

Fix sequence in a live environment

This sequence stops the failing deploy from spreading, preserves evidence, proves the fix against real histories, and records which workflows were reset or left alone. Each step ends with a check so the team knows when it can move on.

  1. Halt the bad deploy first

    The on-call engineer pauses the rollout of the workers that introduced the change, or rolls the worker deployment back to the last build that replayed cleanly. Stop any automated pipeline that would ship the same commit again. Confirm the step is done when the worker image or version running on every worker pool matches the build you intend to keep, and no new deployment is in progress. Confirm the exact mechanism (rollback command, Kubernetes rollout pause, or CI freeze) with your own platform team, since it depends on how your workers are deployed.

  2. Capture the failing histories

    Before any reset or termination, export the event history of a representative set of workflows that show WorkflowTaskFailed with a non-determinism cause. Use the Temporal CLI or Web UI to save each history as JSON, and record the workflow IDs, run IDs, workflow types, task queue, and the failure message. Store the files in your incident record so they remain available after the workflows are changed. Confirm the step is done when every exported history opens, and the failure event names the same command or error the team saw in the worker logs.

  3. Count the affected executions

    Run a visibility query for open workflows of the affected workflow types that have a task failure, and compare the result against the number of workflows you expect to be stuck. Keep the query and its result with the incident notes so you can measure progress later. Confirm the step is done when you have a baseline count and a list of workflow types, and you know which histories were started before the change and which after. Confirm the query syntax supported by your visibility store, because it differs between backends.

  4. Reproduce the failure with a replay test

    Using the captured history file, write a replay test in the SDK's test or replay tooling that runs the workflow code from the broken commit against that history. Run the same test against the last known good commit to confirm it passes there. The developer owns this step, with a second reviewer checking that the test uses the exact history file and not a regenerated one. Confirm the step is done when the replay test fails on the new code with the same non-determinism error and passes on the old code.

  5. Apply the chosen fix

    Based on the replay result, apply one of the fixes covered earlier on this page: a patch or version gate that keeps the old branch for workflows already in flight, a versioning approach that pins old executions to the old code, or a reset of the affected workflows to a point before the divergence. Commit the change with the replay test included. Confirm the step is done when the replay test passes on the fixed code for every captured history, and the change has passed your normal review and test gates.

  6. Redeploy workers and verify task recovery

    Deploy the fixed build to the worker pools that serve the affected task queues, then watch the failed workflow tasks in the Web UI or your metrics dashboard. Stuck workflows should retry their workflow tasks on the new code and continue. Confirm the step is done when the count of failed workflow tasks from your baseline query falls to zero or to the set you chose to reset, and no new WorkflowTaskFailed events with non-determinism causes appear over a monitoring window your team sets.

  7. Reset or leave each workflow and record the outcome

    For each workflow that could not recover on the fixed code, decide whether to reset it to a chosen event, or leave it to finish on its own, following the reset and batch guidance covered in the sibling pages. Record each workflow ID, the decision, the reset point if used, and who approved it in the incident log. Confirm the step is done when every workflow in the baseline list has a recorded outcome, and the final visibility query shows no unexplained open failures for the affected workflow types.

How to test workflow changes before they reach running executions

Replay testing against captured workflow histories is the main safeguard against non-determinism errors, and it should run before a change reaches a worker that serves live executions. A replay check takes a recorded event history from a running or recently completed workflow, feeds it to the new workflow code, and confirms the code produces the same commands in the same order. If a change reorders an activity call, adds a timer ahead of an existing one, or removes a child workflow start, the replay fails in the pipeline instead of as a WorkflowTaskFailed event in production. Add this check as a required stage in the release pipeline for every service that hosts workflow code, and block deployment when it fails.

The replay check is only as good as the histories behind it. Keep a library of representative histories in version control or an artifact store, exported from the namespace you run, and cover the workflow types, branches and signal or timer paths that your current running executions actually take. Include histories from before the last deployment that changed workflow logic, because those are the executions most likely to be replayed against new code. Store the history files with the workflow type and the code version that produced them, so a reviewer can see which histories a change was tested against. Confirm with your SDK's documentation which replay test helpers exist, how they load history files, and whether they can run in CI without a Temporal Service.

Code review should make version guards visible. Every change to workflow logic that alters command order needs a patch or versioning marker in the diff, the reviewer should confirm which histories the guard protects, and the pull request should state when the old branch can be removed. Decide in advance who approves workflow logic changes: typically a code owner for the service plus someone who understands the running execution population, such as the on-call platform engineer. Agree on whether an emergency fix can skip the replay stage and who records that decision afterward. The approval record should name the histories tested and the reset or termination plan if the change still breaks running executions.

Security and operational risks while fixing live workflows

Fixing a non-determinism error usually means touching live workflows, histories and people with powerful rights. The risks below share one root: a fix that is fast to apply can expose data, repeat side effects or split a fleet across versions. Each card names the control to set and the check to run before and after the change.

Reset can repeat side effects

A reset replays workflow code from an earlier point, and activities after that point can run again. If an activity charges a card, sends a message or creates a record, a re-run can duplicate the effect. Before resetting, list the activities after the reset point and confirm each is idempotent or guarded by a business key. Ask whether the reset point should be moved past completed side effects instead.

Temporal security docs

Histories hold sensitive payloads

Workflow histories store the inputs and results of every activity, and these can include personal, financial or health data. Investigators who open histories to find the non-deterministic change see that data too. Confirm whether payloads are encrypted with a custom codec, and restrict who can read event histories in the Web UI and CLI during the investigation.

Reset and terminate rights need limits

Resetting or terminating workflows in bulk is the most destructive action an operator can take on a namespace. Limit these rights to a small operator group using namespace roles, and do not grant them to general developers. Self-hosted Temporal with no Authorizer configured allows every API request, so confirm the access controls are configured and tested in your environment before relying on them.

Default without Authorizer
noopAuthorizer
Self-hosted security docs

Emergency fixes can bypass review

Under incident pressure, a hotfix may ship straight to production without the usual code review, tests or replay check. A non-determinism fix that skips replay testing can create the same failure in a new form. Require a change record for every production fix that names the workflow type, the offending change, the chosen remedy and the approver, even when the change is made under emergency procedure.

Partial rollouts cause mixed versions

If a patched workflow definition reaches only some worker pods, workers running old and new code can disagree about history replay. Tasks may fail on one pool while succeeding on another, which looks like a random failure. Before rollout, check that all workers serving the task queue run the same build or that the patching or versioning gate is in place, and watch the failure rate per worker version during the change.

Fixes need an audit trail

Operators need evidence that a fix was tested, applied and reviewed after the fact. Keep the change record, the replay test output, the list of reset or terminated workflow IDs and the deployment identifiers together. Confirm where your self-hosted deployment stores operator actions and how long those records are kept, because the answer depends on your logging and retention setup.

What to confirm before relying on a fix

On a self-hosted Service, you own the server version, the worker versions and the operational levers that a fix may depend on. Before you rely on a patch or a reset, confirm which Temporal Server version runs in every environment where the workflow executes, and whether the Helm chart or deployment method matches the server image. The Temporal upgrade documentation explains that compatibility is guaranteed only between successive minor versions, so a fix validated on one minor line may not be a safe assumption on another.

  • Server and schema versions: Record the exact server image and the persistence schema version in each cluster, and confirm that the schema upgrade ran before the server upgrade where release notes required it.
  • Helm chart compatibility: Confirm the chart version against the server image, since the deployment docs flag chart versions that do not work with newer server images.
  • Reset permissions: Confirm that the namespace and the operators' access rights allow the reset operation for the affected workflow types, and that your Authorizer or ClaimMapper grants that role.
  • Retention and history access: Confirm the namespace retention period still covers the histories you need to replay or reset.
  • Network exposure: Confirm that frontend access used for the fix is limited to trusted internal networks.

Confirm each item with your own cluster configuration and the vendor documentation for your exact version, since exact limits and defaults may change between releases.

Questions teams ask before fixing Temporal non-determinism errors

How long does it take to fix a Temporal non-determinism error?

The duration depends mainly on how many workflow executions are stuck, how many code paths changed, and how quickly the team can reproduce the failure in a replay environment. A single stuck workflow caused by one changed condition is usually a short investigation, while a fleet of long-running workflows spanning several releases needs more time to classify, patch and verify. Ask any partner to split the work into diagnosis, the fix itself, rollout to workers, and the recovery of affected executions, and to state which of those depends on your change windows. No duration is given here because it varies widely with the code involved.

Can our own team fix Temporal non-determinism errors internally?

Often yes, if at least one engineer knows the workflow code well, can read event histories, and can run replay tests locally. The work becomes harder when the change is spread across several releases, when workflows have been running for months, or when the people who wrote the original code have left. Three questions help decide: whether the team can name the exact command that produced the failing task, whether it has a replay test that fails on the bad change, and whether someone can approve a patch in production without a second review cycle. If any answer is no, a short outside review of the diagnosis is a reasonable middle option.

What do we need to give an outside team to start?

The work needs four things from your side: read access to workflow event histories for the affected executions, the code owners for the workflow and activity definitions, a replay environment that runs the same SDK and workflow code versions as production, and a change window for deploying patches and any reset. Access to histories must be handled under your data policy, since payloads can contain personal or regulated data, so ask whether payload encryption or a codec server is in use. Also confirm who approves production changes and how the team will be reached during the window.

What does a fix cost, and what drives the cost up?

Cost comes from the people doing the work: investigation time, the engineering effort to write and test the patch or version change, the review and rollout effort, and the recovery work on affected executions. Costs rise with the number of affected workflows, the number of distinct non-deterministic changes, how many worker versions are still running, and whether replay tests need to be built from scratch. Costs fall when histories are well kept, tests already exist and the code owners are available. A fixed-scope quote should list each of these components separately. DeployOpen does not publish a price list, so the quote follows from the written scope and depends on the number of affected workflows and the code involved.

When is a reset safer than a patch for Temporal workflows?

A reset is generally safer when the bad change is recent, the affected workflows are few, and the new code can replay correctly from an earlier point in history. A patch or versioning change is safer when many long-running workflows are mid-flight and must keep their current history, because it lets existing executions follow the old branch while new executions follow the new one. Resetting also discards work done after the reset point, so check whether activities already ran with external side effects. The choice should be made per workflow type after replay testing, not as one decision for the whole fleet.

How do we check that a patch will not break running workflows?

Test the new code by replaying real or copied histories from production against the new worker build before any rollout. Replay confirms whether the new code makes the same decisions as the recorded history for each workflow version. Teams should also run the replay tests in continuous integration so the next change is checked the same way. Ask whether the outside team will provide replay test cases that cover each affected workflow type and whether those tests will remain in your repository after the engagement ends.

Does DeployOpen issue a guarantee that workflows will run correctly after the fix?

DeployOpen delivers the diagnosis, the agreed fix and evidence from replay testing within the written scope, but it cannot guarantee how your production system behaves after changes are made. Behavior also depends on activities, external systems and future code changes that sit outside any single fix. Before work starts, ask for the deliverables in writing, including which histories were tested, which workflow types were covered, and what handover material your team receives.

What support should we expect after the non-determinism fix?

Most engagements end with a handover covering the versioning approach, the replay test suite, a checklist for future workflow changes and the runbook for recovering stuck tasks. Ongoing support, upgrades and continuous testing are available as retainers if your team wants help with later Temporal Server or SDK changes. Ask what is included in the handover, how questions are handled after it closes, and whether a retainer covers new incidents.

How DeployOpen works on this

DeployOpen approaches non-determinism errors as a controlled change to your Temporal workflow code and its deployment, not as a quick restart. We start from the failing history in your own environment, agree the fix in a written scope, and hand over the patched code, runbook and verification evidence your team can reuse.

How we scope

  • Collect WorkflowTaskFailed events, namespace names and the worker versions that ran each affected workflow
  • Agree in writing which workflow types, task queues and deployed versions are in scope
  • Confirm whether a fix will use patching, versioning, reset or a combination of these
  • Record who approves changes to production workflow code and when reset windows apply

How we build

  • Reproduce the failure by replaying captured histories against the candidate workflow code
  • Locate the command sequence change that caused the mismatch and document it
  • Implement the fix with patch markers or versioned code paths, with replay tests kept in your repository
  • Test the fix against representative histories in a non-production namespace before any rollout

How we hand over

  • Deliver the code change, replay test suite and a written record of the root cause
  • Provide a runbook covering how to identify, triage and clear future non-determinism failures
  • Walk your engineers through the deployment order for workers and the cleanup of patch markers
  • Document any reset commands used, with the workflow IDs and reset points involved

How we support

  • Fixed-scope engagements are agreed in writing before work starts, and a quote follows from that scope
  • Ongoing support, upgrades and continuous testing are available as a retainer
  • Confirm with DeployOpen which Temporal Server version and SDK your fix must support before starting
  • Plan retesting after each later change to workflow code or the Temporal Server upgrade path

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.