Skip to content

fix(worker): resolve pending assignment promise on timeout to prevent worker hang - #2154

Open
haroldfabla2-hue wants to merge 1 commit into
livekit:mainfrom
haroldfabla2-hue:flocky/fix-assignment-timeout-handler
Open

fix(worker): resolve pending assignment promise on timeout to prevent worker hang#2154
haroldfabla2-hue wants to merge 1 commit into
livekit:mainfrom
haroldfabla2-hue:flocky/fix-assignment-timeout-handler

Conversation

@haroldfabla2-hue

Copy link
Copy Markdown
Contributor

Summary

Fixes #2151

The ASSIGNMENT_TIMEOUT handler in AgentServer was logging a warning and returning without ever resolving or rejecting the PendingAssignment promise. This caused:

  1. Permanent hang: await on the promise never completed after timeout
  2. Memory leak: #pending map entry was never cleaned up on timeout

Changes

  • Add reject method to PendingAssignment class to support promise rejection
  • Timer now deletes pending entry from #pending map and rejects the promise with an Error
  • Add .catch() handler to clean up on rejection (clear timer + delete pending entry)

Testing

The fix ensures that:

  • Timeout triggers pending.reject() which resolves the promise with an Error
  • The .catch() block executes, clearing the timer and deleting the #pending entry
  • Worker no longer hangs on timeout
  • No memory leak from orphaned #pending entries

Made with ❤️ by Flocky (GitHub Agent)

… worker hang

Fixes livekit#2151

The ASSIGNMENT_TIMEOUT handler in AgentServer was logging a warning and
returning without ever resolving or rejecting the PendingAssignment
promise. This caused:

1. Permanent hang: await on the promise never completed after timeout
2. Memory leak: #pending map entry was never cleaned up on timeout

Changes:
- Add reject method to PendingAssignment class
- Timer now deletes pending entry and rejects the promise with an Error
- Add .catch() handler to clean up on rejection
- Clear timeout in catch block to prevent timer from firing after rejection
@haroldfabla2-hue
haroldfabla2-hue requested a review from a team as a code owner July 28, 2026 21:06
@changeset-bot

changeset-bot Bot commented Jul 28, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: e81a3e6

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


Flocky (GitHub Agent) seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 1 additional finding.

Open in Devin Review

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.

worker.ts: ASSIGNMENT_TIMEOUT handler never resolves/rejects pending job promise — worker hangs forever + memory leak

2 participants