fix(loading-spinner): stuck spinner after rapid concurrent requests#486
Merged
nicdavidson merged 1 commit intodevelopfrom Apr 22, 2026
Merged
fix(loading-spinner): stuck spinner after rapid concurrent requests#486nicdavidson merged 1 commit intodevelopfrom
nicdavidson merged 1 commit intodevelopfrom
Conversation
The loading interceptor toggles DfLoadingSpinnerService.active per request. The service maintains a counter but decided whether to schedule a BehaviorSubject emit by comparing shouldBeActive against active$.value — stale during rapid toggles because emits are deferred with setTimeout. Reproduction: event-script create form fires three concurrent GETs (services list + two source control+file lookups). All complete inside one tick; the final decrement is evaluated while pending setTimeouts haven't fired, so the 'active$.value (false) !== shouldBeActive (false)' check is FALSE and the deactivate is skipped. The earlier queued next(true) then fires and the spinner is stuck on forever until navigation. Fix: decide transitions from the counter directly (wasActive vs isActive) and use queueMicrotask. queueMicrotask still runs after the current change- detection pass (so no ExpressionChangedAfterItHasBeenCheckedError) but before the next macrotask, which keeps emit ordering consistent. Also rebuilds dist/ so composer consumers pick up the fix.
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
DfLoadingSpinnerService.activedecided whether to schedule aBehaviorSubjectemit by comparingshouldBeActiveagainstactive$.value— stale during rapid toggles because emits are deferred withsetTimeout. When three concurrent requests started and finished inside one tick (event-script create form: services list + twosource control,filelookups), the final decrement was evaluated while pending setTimeouts hadn't fired, so thefalse !== falsecheck evaluated false and the deactivate was skipped. The earlier queuednext(true)then fired and the spinner was stuck on until navigation.Fix
Decide transitions from the counter directly (wasActive vs isActive) and use
queueMicrotask.queueMicrotaskstill runs after the current change-detection pass (noExpressionChangedAfterItHasBeenCheckedError) but before the next macrotask, which keeps emit ordering consistent with request ordering.Also rebuilds
dist/so composer consumers pick up the fix.Test plan