Problem
getMethodNameForAction() in packages/durabletask-js/src/worker/index.ts (line 36-55) only handles 4 of the 7 valid OrchestratorAction types: SCHEDULETASK, CREATETIMER, CREATESUBORCHESTRATION, and COMPLETEORCHESTRATION.
The three missing cases are:
SENDEVENT (produced by context.sendEvent())
SENDENTITYMESSAGE (produced by context.callEntity(), context.signalEntity(), context.lockEntities())
TERMINATEORCHESTRATION
Root Cause
When orchestration code is changed between runs (a non-determinism scenario), the orchestration executor calls getWrongActionTypeError() which in turn calls getMethodNameForAction() to produce a descriptive NonDeterminismError message. If the mismatched action is a SENDEVENT, SENDENTITYMESSAGE, or TERMINATEORCHESTRATION type, getMethodNameForAction() falls through to the default case and throws a generic Error("Unknown action type: N") instead of returning the method name.
This means the user sees an unhelpful "Unknown action type: 5" crash instead of the intended diagnostic message like "A previous execution called callActivity with ID=1, but the current execution is instead trying to call sendEvent...".
Scenario
- Version 1 of an orchestrator calls
context.callActivity("myActivity") at sequence ID 1
- An instance starts running and completes the activity
- Code is updated: version 2 calls
context.sendEvent("instance", "event") at sequence ID 1
- On replay, history has
TaskScheduled at ID=1, but _pendingActions[1] is now a SENDEVENT action
handleTaskScheduled() detects the mismatch and calls getWrongActionTypeError(1, "callActivity", sendEventAction)
getMethodNameForAction(sendEventAction) throws Error("Unknown action type: 5") instead of returning "sendEvent"
The same pattern applies to entity orchestrations that use callEntity/signalEntity/lockEntities.
Proposed Fix
Add the three missing cases to the switch statement in getMethodNameForAction().
Impact
Severity: Medium — Affects error diagnostics for non-determinism in orchestrations using entities or sendEvent. Users get an unhelpful crash error instead of the proper NonDeterminismError that explains the history mismatch.
Problem
getMethodNameForAction()inpackages/durabletask-js/src/worker/index.ts(line 36-55) only handles 4 of the 7 validOrchestratorActiontypes:SCHEDULETASK,CREATETIMER,CREATESUBORCHESTRATION, andCOMPLETEORCHESTRATION.The three missing cases are:
SENDEVENT(produced bycontext.sendEvent())SENDENTITYMESSAGE(produced bycontext.callEntity(),context.signalEntity(),context.lockEntities())TERMINATEORCHESTRATIONRoot Cause
When orchestration code is changed between runs (a non-determinism scenario), the orchestration executor calls
getWrongActionTypeError()which in turn callsgetMethodNameForAction()to produce a descriptiveNonDeterminismErrormessage. If the mismatched action is aSENDEVENT,SENDENTITYMESSAGE, orTERMINATEORCHESTRATIONtype,getMethodNameForAction()falls through to the default case and throws a genericError("Unknown action type: N")instead of returning the method name.This means the user sees an unhelpful
"Unknown action type: 5"crash instead of the intended diagnostic message like"A previous execution called callActivity with ID=1, but the current execution is instead trying to call sendEvent...".Scenario
context.callActivity("myActivity")at sequence ID 1context.sendEvent("instance", "event")at sequence ID 1TaskScheduledat ID=1, but_pendingActions[1]is now aSENDEVENTactionhandleTaskScheduled()detects the mismatch and callsgetWrongActionTypeError(1, "callActivity", sendEventAction)getMethodNameForAction(sendEventAction)throwsError("Unknown action type: 5")instead of returning"sendEvent"The same pattern applies to entity orchestrations that use
callEntity/signalEntity/lockEntities.Proposed Fix
Add the three missing cases to the switch statement in
getMethodNameForAction().Impact
Severity: Medium — Affects error diagnostics for non-determinism in orchestrations using entities or
sendEvent. Users get an unhelpful crash error instead of the properNonDeterminismErrorthat explains the history mismatch.