Skip to content

fix: set instanceId on ActivityResponse in failure path#122

Merged
YunchuWang merged 1 commit intomainfrom
copilot-finds/bug/fix-activity-response-missing-instanceid
Mar 3, 2026
Merged

fix: set instanceId on ActivityResponse in failure path#122
YunchuWang merged 1 commit intomainfrom
copilot-finds/bug/fix-activity-response-missing-instanceid

Conversation

@YunchuWang
Copy link
Member

The activity execution error handler in TaskHubGrpcWorker was not setting the instanceId field on the ActivityResponse when an activity throws an exception. The success path correctly called res.setInstanceid(instanceId), but the catch block omitted it.

This deviates from the .NET SDK behavior, which always sets InstanceId on the ActivityResponse regardless of outcome. The missing field could cause issues with sidecar response routing or logging for failed activities.

Summary

What changed?

Why is this change needed?

Issues / work items

  • Resolves #
  • Related #

Project checklist

  • Release notes are not required for the next release
    • Otherwise: Notes added to CHANGELOG.md
  • Backport is not required
    • Otherwise: Backport tracked by issue/PR #issue_or_pr
  • All required tests have been added/updated (unit tests, E2E tests)
  • Breaking change?
    • If yes:
      • Impact:
      • Migration guidance:

AI-assisted code disclosure (required)

Was an AI tool used? (select one)

  • No
  • Yes, AI helped write parts of this PR (e.g., GitHub Copilot)
  • Yes, an AI agent generated most of this PR

If AI was used:

  • Tool(s):
  • AI-assisted areas/files:
  • What you changed after AI output:

AI verification (required if AI was used):

  • I understand the code and can explain it
  • I verified referenced APIs/types exist and are correct
  • I reviewed edge cases/failure paths (timeouts, retries, cancellation, exceptions)
  • I reviewed concurrency/async behavior
  • I checked for unintended breaking or behavior changes

Testing

Automated tests

  • Result: Passed / Failed (link logs if failed)

Manual validation (only if runtime/behavior changed)

  • Environment (OS, Node.js version, components):
  • Steps + observed results:
    1.
    2.
    3.
  • Evidence (optional):

Notes for reviewers

  • N/A

The activity execution error handler in TaskHubGrpcWorker was not setting
the instanceId field on the ActivityResponse when an activity throws an
exception. The success path correctly called res.setInstanceid(instanceId),
but the catch block omitted it.

This deviates from the .NET SDK behavior, which always sets InstanceId on
the ActivityResponse regardless of outcome. The missing field could cause
issues with sidecar response routing or logging for failed activities.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 3, 2026 17:26
Copy link

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

Fixes an inconsistency in the worker’s activity completion reporting so that ActivityResponse.instanceId is always populated, matching .NET SDK behavior and preventing missing-instance routing/logging issues on failure.

Changes:

  • Set ActivityResponse.instanceId in the activity execution failure path in TaskHubGrpcWorker.
  • Add unit coverage to verify instanceId is set for activity success, Error failures, and non-Error throws.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
packages/durabletask-js/src/worker/task-hub-grpc-worker.ts Ensures ActivityResponse.instanceId is set in the catch/failure branch.
packages/durabletask-js/test/worker-activity-response.spec.ts Adds tests asserting instanceId is present on ActivityResponse in success and failure scenarios.

@YunchuWang YunchuWang merged commit c5722a2 into main Mar 3, 2026
32 checks passed
@YunchuWang YunchuWang deleted the copilot-finds/bug/fix-activity-response-missing-instanceid branch March 3, 2026 17:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants