fix(menubar): await terminationHandler, not a blocked queue thread (real fix for the Loading wedge)#462
Merged
Conversation
…read; cap CLI spawns The #426 fix moved waitUntilExit and its timeout onto the same global(qos:.utility) queue. Under sustained load every utility worker blocked in waitUntilExit, so the timeout could never be scheduled to kill them and the menubar wedged on Loading forever (confirmed via sample after ~a week of soak). Await process.terminationHandler (fires on a Foundation queue, blocks no worker) so the timeout always has a free thread. Add an actor-based async semaphore capping concurrent CLI spawns at 6.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes the menubar wedging on "Loading…" with an unresponsive popover after sustained idle/use — the exact symptom #426 targeted but did not actually resolve. A build carrying #426's
runProcessstill wedged after ~a week of soak; a livesampleshowed ~80 threads parked inDataClient.runProcess → waitUntilExitwith the timeout never firing.Root cause
#426 moved the blocking
waitUntilExitand its timeout watchdog onto the sameglobal(qos:.utility)queue. Under sustained load every utility worker ends up blocked inwaitUntilExit, so the timeout (same queue) can never be scheduled to kill the stuck processes — re-creating the original deadlock at the larger global-queue scale (which is why it took ~a week to saturate instead of minutes). A watchdog living on the queue it's meant to rescue can't fire once that queue is saturated.The CLI itself is healthy (
status --format menubar-json --period 30daysreturns in 16s) — the wedge is entirely in the Swift subprocess-wait layer.Fix
process.terminationHandler(set beforerun(), bridged through a one-shotProcessExitSignal) instead of parking a worker thread inwaitUntilExit. terminationHandler fires on a Foundation-managed queue and blocks nothing, so the timeout always has a free thread to fire on.AsyncSemaphorecapping concurrent CLI spawns at 6 so a wake-burst of refreshes can't fan out into dozens of node processes.Testing
swift buildclean. Rebuilt + relaunched the menubar; livesampleof the new build shows zerowaitUntilExitframes and no CLI pile-up.Heads-up: pre-existing red CI on
main(unrelated to this PR)swift testcurrently fails to compile two test files onmain—ContributionHeatmapTestsandAppStoreRefreshRecoveryTests— missinglocalModelSavings/savingsUSDargs after a payload field was added during the week. This PR doesn't touch those files; it's a separate pre-existing breakage. Can fix in a follow-up.Supersedes the same-queue approach merged in #426.