@@ -2278,7 +2278,9 @@ def _receiver_condition_wait_bindings() -> dict[int, str | None]:
22782278 # When multiple signals arrive while the task woken by the
22792279 # first signal is still leased, the server records those
22802280 # later SignalReceived rows before the task's next
2281- # ConditionWaitOpened row. Replay them at that next wait.
2281+ # ConditionWaitOpened row. Replay them at that next wait
2282+ # even if their stored workflow_sequence still points at
2283+ # the wait that was open when the signal was accepted.
22822284 for receiver_index in receivers_since_wait [1 :]:
22832285 if receiver_index is not None :
22842286 bindings [receiver_index ] = wait_id
@@ -2296,8 +2298,8 @@ def _receiver_condition_wait_bindings() -> dict[int, str | None]:
22962298 prefix_receivers .append (index )
22972299 continue
22982300
2299- receivers_since_wait .append (None if explicit_sequence else index )
2300- if len (receivers_since_wait ) == 1 and not explicit_sequence :
2301+ receivers_since_wait .append (index )
2302+ if len (receivers_since_wait ) == 1 :
23012303 bindings [index ] = current_wait_id
23022304 continue
23032305
@@ -2404,11 +2406,12 @@ def _receiver_condition_wait_bindings() -> dict[int, str | None]:
24042406 signal_name = payload .get ("signal_name" )
24052407 if isinstance (signal_name , str ) and signal_name :
24062408 workflow_sequence = _workflow_sequence (payload )
2407- condition_wait_id = (
2408- condition_wait_ids_by_sequence .get (workflow_sequence )
2409- if workflow_sequence is not None
2410- else receiver_condition_wait_ids .get (event_index )
2411- )
2409+ if event_index in receiver_condition_wait_ids :
2410+ condition_wait_id = receiver_condition_wait_ids [event_index ]
2411+ elif workflow_sequence is not None :
2412+ condition_wait_id = condition_wait_ids_by_sequence .get (workflow_sequence )
2413+ else :
2414+ condition_wait_id = None
24122415 pending_receivers .append (_PendingReceiver (
24132416 result_index = len (resolved_results ),
24142417 kind = "signal" ,
@@ -2429,11 +2432,12 @@ def _receiver_condition_wait_bindings() -> dict[int, str | None]:
24292432 update_name = payload .get ("update_name" )
24302433 if isinstance (update_name , str ) and update_name :
24312434 workflow_sequence = _workflow_sequence (payload )
2432- condition_wait_id = (
2433- condition_wait_ids_by_sequence .get (workflow_sequence )
2434- if workflow_sequence is not None
2435- else receiver_condition_wait_ids .get (event_index )
2436- )
2435+ if event_index in receiver_condition_wait_ids :
2436+ condition_wait_id = receiver_condition_wait_ids [event_index ]
2437+ elif workflow_sequence is not None :
2438+ condition_wait_id = condition_wait_ids_by_sequence .get (workflow_sequence )
2439+ else :
2440+ condition_wait_id = None
24372441 pending_receivers .append (_PendingReceiver (
24382442 result_index = len (resolved_results ),
24392443 kind = "update" ,
0 commit comments