🐛 [RUM Profiler] Fix stateReason not updated on stop and cleanup tasks accumulation#4171
Open
thomasbertet wants to merge 2 commits intomainfrom
Open
🐛 [RUM Profiler] Fix stateReason not updated on stop and cleanup tasks accumulation#4171thomasbertet wants to merge 2 commits intomainfrom
thomasbertet wants to merge 2 commits intomainfrom
Conversation
stopProfilerInstance did not update stateReason when the profiler was already in stopped state. This meant calling stop() after SESSION_EXPIRED left stateReason as 'session-expired', causing SESSION_RENEWED to restart the profiler against the user's intent.
The array was never reset after forEach, causing stale cleanup function references to accumulate across start/stop cycles.
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.
Motivation
Two issues found in the profiler state machine after the recent sync state fix (#4152):
stopProfilerInstancedoes not updatestateReasonwhen the profiler is already instoppedstate. IfSESSION_EXPIREDfires first (settingstateReasontosession-expired), then the user callsstop(), the reason stayssession-expired. On the nextSESSION_RENEWED, the profiler restarts against the user's intent.globalCleanupTasksarray is never cleared afterforEachcleanup instopProfiling. Stale function references accumulate across start/stop cycles.Changes
stopProfilerInstance: when already stopped, updatestateReasonif the new reason isstopped-by-user, so thatSESSION_RENEWEDrespects the user's explicit stop.stopProfiling: resetglobalCleanupTasks.length = 0after invoking all cleanup functions.Test instructions
yarn test:unit --spec packages/rum/src/domain/profiling/profiler.spec.tsChecklist