Skip to content

fix: Use toLowerCase() consistently for event name normalization#180

Open
YunchuWang wants to merge 1 commit intomainfrom
copilot-finds/bug/fix-event-name-locale-mismatch
Open

fix: Use toLowerCase() consistently for event name normalization#180
YunchuWang wants to merge 1 commit intomainfrom
copilot-finds/bug/fix-event-name-locale-mismatch

Conversation

@YunchuWang
Copy link
Copy Markdown
Member

Fixes #171

Problem

waitForExternalEvent() in runtime-orchestration-context.ts uses toLocaleLowerCase() to normalize event names, while handleEventRaised() in orchestration-executor.ts uses toLowerCase(). These produce different results in certain locales (e.g., Turkish), causing orchestrations to hang indefinitely.

Changes

  • Change toLocaleLowerCase() to toLowerCase() in waitForExternalEvent() to match the executor's behavior
  • Ensures consistent event name matching across locales
  • Fixes determinism violation: toLocaleLowerCase() depends on system locale

Copilot AI review requested due to automatic review settings March 14, 2026 22:00
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a locale-dependent mismatch in external event name normalization in the DurableTask JS orchestration runtime to prevent waitForExternalEvent() from hanging indefinitely in certain locales (e.g., Turkish), aligning behavior with the executor and preserving orchestration determinism.

Changes:

  • Normalize external event names using toLowerCase() (instead of toLocaleLowerCase()) in RuntimeOrchestrationContext.waitForExternalEvent().
  • Add executor regression tests for case-insensitive external event matching, including the “buffered event arrives before wait” scenario.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
packages/durabletask-js/src/worker/runtime-orchestration-context.ts Switches event-name normalization to locale-independent toLowerCase() to match executor behavior and avoid nondeterminism.
packages/durabletask-js/test/orchestration_executor.spec.ts Adds regression tests intended to validate case-insensitive event name matching across the wait/raise boundary (including buffered events).

You can also share your feedback on Copilot code review. Take the survey.

Comment thread packages/durabletask-js/test/orchestration_executor.spec.ts
@YunchuWang YunchuWang force-pushed the copilot-finds/bug/fix-event-name-locale-mismatch branch from 92623d4 to a69f93a Compare April 15, 2026 19:08
…matching

waitForExternalEvent() used toLocaleLowerCase() to normalize event names,
while handleEventRaised() in the orchestration executor used toLowerCase().
In locales where these produce different results (e.g., Turkish 'I' -> dotless
'ı' vs 'i'), event names registered by waitForExternalEvent would not match
events delivered by the executor, causing orchestrations to hang indefinitely.

This also violates the determinism invariant: the same orchestration code
running on machines with different locale settings would produce different
event name keys, potentially breaking replay.

The fix changes toLocaleLowerCase() to toLowerCase() in
waitForExternalEvent() to be consistent with the executor.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@YunchuWang YunchuWang force-pushed the copilot-finds/bug/fix-event-name-locale-mismatch branch from a69f93a to f56785f Compare April 15, 2026 20:48
github-actions bot pushed a commit that referenced this pull request Apr 15, 2026
Verification sample: examples/verification/pr-180-event-name-locale.ts

Scenario: External event name matching with mixed case names works correctly
after switching from toLocaleLowerCase() to toLowerCase(). Validates that
orchestrations waiting for UPPER_CASE event names receive events raised with
lowercase names.

Generated by pr-verification-agent

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions github-actions bot added sample-verification-added PR has been verified with a sample application and removed pending-verification labels Apr 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

sample-verification-added PR has been verified with a sample application

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[copilot-finds] Bug: waitForExternalEvent uses toLocaleLowerCase() causing locale-dependent event name mismatch

2 participants