Skip to content

fix(core): resolve daemon client reconnect queue deadlock#34284

Merged
FrozenPandaz merged 1 commit intomasterfrom
fix/daemon-client-reconnect-queue-deadlock
Feb 2, 2026
Merged

fix(core): resolve daemon client reconnect queue deadlock#34284
FrozenPandaz merged 1 commit intomasterfrom
fix/daemon-client-reconnect-queue-deadlock

Conversation

@FrozenPandaz
Copy link
Copy Markdown
Contributor

Current Behavior

When the daemon dies while processing a request, the reconnect logic adds the retry back to the promise-based queue. However, the original request is still blocked in the queue waiting for a response that will never come (the socket is dead). This creates a deadlock:

  1. Original request (fn1) is blocked awaiting a promise that will never resolve
  2. Retry request (fn2) is queued but can't execute until fn1 completes
  3. fn1 can't complete because it's waiting on the dead socket

Expected Behavior

When reconnecting after daemon death, the retry should resolve the pending promise that the original queue entry is waiting on, allowing the queue to proceed normally.

Related Issue(s)

Solution

Instead of re-queuing the retry through sendToDaemonViaQueue (which adds to the end of the queue), we now call sendMessageToDaemon directly. This resolves the pending promise that fn1 is waiting on, allowing it to complete naturally and the queue to proceed.

Also removed the now-unused decrementQueueCounter method from PromisedBasedQueue.

When a request is retried after daemon dies, the retry was being added
back to the promise queue while the original request was still blocked
waiting for a response that would never come. This caused a deadlock
where the retry couldn't execute until the original completed.

Fix by directly calling sendMessageToDaemon instead of going through
the queue, which resolves the pending promise the original queue entry
is waiting on, allowing it to complete naturally.
@vercel
Copy link
Copy Markdown

vercel Bot commented Feb 2, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
nx-dev Ready Ready Preview Feb 2, 2026 4:09pm

Request Review

@nx-cloud
Copy link
Copy Markdown
Contributor

nx-cloud Bot commented Feb 2, 2026

View your CI Pipeline Execution ↗ for commit 71be832

Command Status Duration Result
nx affected --targets=lint,test,test-kt,build,e... ✅ Succeeded 45m 16s View ↗
nx run-many -t check-imports check-lock-files c... ✅ Succeeded 2m 48s View ↗
nx-cloud record -- nx-cloud conformance:check ✅ Succeeded 11s View ↗
nx-cloud record -- nx format:check ✅ Succeeded 2s View ↗
nx-cloud record -- nx sync:check ✅ Succeeded <1s View ↗

☁️ Nx Cloud last updated this comment at 2026-02-02 16:53:49 UTC

@netlify
Copy link
Copy Markdown

netlify Bot commented Feb 2, 2026

Deploy Preview for nx-docs ready!

Name Link
🔨 Latest commit 71be832
🔍 Latest deploy log https://app.netlify.com/projects/nx-docs/deploys/6980ca86865b4a0008ddaee6
😎 Deploy Preview https://deploy-preview-34284--nx-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@FrozenPandaz FrozenPandaz marked this pull request as ready for review February 2, 2026 16:24
@FrozenPandaz FrozenPandaz requested a review from a team as a code owner February 2, 2026 16:24
@FrozenPandaz FrozenPandaz requested a review from MaxKless February 2, 2026 16:24
@FrozenPandaz FrozenPandaz merged commit 89aa25e into master Feb 2, 2026
20 checks passed
@FrozenPandaz FrozenPandaz deleted the fix/daemon-client-reconnect-queue-deadlock branch February 2, 2026 17:05
FrozenPandaz added a commit that referenced this pull request Feb 3, 2026
## Current Behavior

When the daemon dies while processing a request, the reconnect logic
adds the retry back to the promise-based queue. However, the original
request is still blocked in the queue waiting for a response that will
never come (the socket is dead). This creates a deadlock:

1. Original request (`fn1`) is blocked awaiting a promise that will
never resolve
2. Retry request (`fn2`) is queued but can't execute until `fn1`
completes
3. `fn1` can't complete because it's waiting on the dead socket

## Expected Behavior

When reconnecting after daemon death, the retry should resolve the
pending promise that the original queue entry is waiting on, allowing
the queue to proceed normally.

## Related Issue(s)

<!-- No specific issue, discovered during development -->

## Solution

Instead of re-queuing the retry through `sendToDaemonViaQueue` (which
adds to the end of the queue), we now call `sendMessageToDaemon`
directly. This resolves the pending promise that `fn1` is waiting on,
allowing it to complete naturally and the queue to proceed.

Also removed the now-unused `decrementQueueCounter` method from
`PromisedBasedQueue`.

(cherry picked from commit 89aa25e)
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Feb 8, 2026

This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request.

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Feb 8, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants