fix(runtime): return the newest worker window from getApplicationLastProfile - #5023
Merged
Merged
Conversation
…Profile When an application ran multiple workers, getApplicationLastProfile resolved a bare application id through the round-robin worker selector, so the pull could land on a worker whose continuous profiler was never started: the call failed intermittently even though another worker had a live profile window. For an application-level id the last profile is now pulled from every worker in parallel, within the same timeout budget, and the newest window is returned - mirroring the preserved overload profile fallback, which already scanned all workers. Explicit application:workerIndex ids keep addressing a single worker. Per-worker failures with fallback codes are ignored as long as at least one worker yields a profile, while other errors are still rethrown. Assisted-by: Claude Code:claude-fable-5 Signed-off-by: Matteo Collina <hello@matteocollina.com>
mcollina
force-pushed
the
fix-get-last-profile-multiple-workers
branch
from
July 27, 2026 14:12
ab5a47c to
3e8911a
Compare
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.
Problem
Same family as #5022, different method:
getApplicationLastProfileresolved a bare application id through the round-robin worker selector. With multiple workers, the live pull could land on a worker whose continuous profiler was never started, fail withPLT_PPROF_PROFILING_NOT_STARTED, find no preserved overload profile, and throw — intermittently, depending on where the rotor pointed. Even when it didn't fail, it could return an arbitrary worker's window instead of the application's most recent one.Fix
There was already an asymmetry pointing at the right semantics: the preserved-overload-profile fallback (
#getPreservedOverloadProfile) treats a bare application id as "scan all workers, return the newest", while the live path picked one arbitrary worker.The live path now matches: for an application-level id,
getLastProfileis pulled from every worker in parallel (new#pullLastProfileshelper), inside the existing singleoptions.timeoutbudget, and the newest window wins.application:workerIndexids keep the current single-worker behavior.PROFILING_NOT_STARTED,NO_PROFILE_AVAILABLE, …) are ignored as long as at least one worker yields a profile; if all fail, the first error flows into the existing preserved-profile fallback exactly as before. Non-fallback errors still rethrow immediately.This is independent of #5022 (which fixes
start/stoppairing): here no pinning is needed because all workers are queried.Testing
TDD from main:
packages/runtime/test/get-last-profile-workers.test.js(new, 4 tests on a 2-worker fixture). The first test reproduced the reported intermittent failure before the fix (consecutive bare-id calls, one of which rotated onto the unprofiled worker) and passes after; the second asserts the newest-across-workers semantics.packages/runtime/test/extensions.test.js: 19/19packages/wattpm-pprof-capture/test/watt-pprof-capture.test.js(covers preserved/overload/blocked-worker paths of this method): 36/36🤖 Generated with Claude Code