Fix progress bars not clearing on completion after React 19 upgrade#7062
Open
nickwesselman wants to merge 3 commits intomainfrom
Open
Fix progress bars not clearing on completion after React 19 upgrade#7062nickwesselman wants to merge 3 commits intomainfrom
nickwesselman wants to merge 3 commits intomainfrom
Conversation
This comment has been minimized.
This comment has been minimized.
The Ink 6 / React 19 upgrade (269f3aa) deferred unmountInk() in ConcurrentOutput to let React 19 flush batched state updates, but missed the same pattern in useAsyncAndUnmount (used by Tasks) and SingleTask. Without the deferral, unmountInk() fires before the setState that triggers `return null` is flushed, so the final render still contains the LoadingBar and it is never erased. Wrap unmountInk() in setImmediate() in both places, matching the existing fix in ConcurrentOutput. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
465d331 to
55dbfc8
Compare
ryancbahan
approved these changes
Mar 20, 2026
Contributor
ryancbahan
left a comment
There was a problem hiding this comment.
Let a note in Slack -- we should merge to fix regression, since this matches code we shipped elsewhere. but this manual management of Node event loop within a React side effect to handle mounting/unmounting feels...very cursed. I'd like us to come back to this.
3 tasks
Contributor
Author
This was referenced Mar 20, 2026
The setImmediate deferral of unmountInk() introduced a race condition when renderSingleTask is called sequentially: the first instance's deferred unmountInk() can fire after the second instance starts, causing the second waitUntilExit() to resolve prematurely. If the second task then throws, the error is silently swallowed because render().catch(reject) never fires. Fix: add onError callback to SingleTask (mirroring onComplete) so errors are propagated directly via the callback rather than relying on waitUntilExit() rejection, which is unreliable across sequential ink renders. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
Differences in type declarationsWe detected differences in the type declarations generated by Typescript for this branch compared to the baseline ('main' branch). Please, review them to ensure they are backward-compatible. Here are some important things to keep in mind:
New type declarationsWe found no new type declarations in this PR Existing type declarationspackages/cli-kit/dist/private/node/ui/components/SingleTask.d.ts@@ -4,8 +4,9 @@ interface SingleTaskProps<T> {
title: TokenizedString;
task: (updateStatus: (status: TokenizedString) => void) => Promise<T>;
onComplete?: (result: T) => void;
+ onError?: (error: Error) => void;
onAbort?: () => void;
noColor?: boolean;
}
-declare const SingleTask: <T>({ task, title, onComplete, onAbort, noColor }: SingleTaskProps<T>) => React.JSX.Element | null;
+declare const SingleTask: <T>({ task, title, onComplete, onError, onAbort, noColor }: SingleTaskProps<T>) => React.JSX.Element | null;
export { SingleTask };
\ No newline at end of file
|
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
269f3aa6) deferredunmountInk()inConcurrentOutputwithsetImmediate()to let React 19 flush batched state updates, but missed the same pattern inuseAsyncAndUnmount(used byTasks) andSingleTaskunmountInk()fires before thesetStatethat triggersreturn nullis flushed, so the final render still contains theLoadingBarand it is never erased from the terminalunmountInk()insetImmediate()in both places, matching the existing fix inConcurrentOutputrenderSingleTaskcalls: ThesetImmediatedeferral introduced a race condition — whenrenderSingleTaskis called sequentially, the first instance's deferredunmountInk()can fire after the second instance starts, causing the secondwaitUntilExit()to resolve prematurely. If the second task throws, the error is silently swallowed (the promise never settles). Fix: addonErrorcallback toSingleTask(mirroringonComplete) so errors propagate directly rather than relying onwaitUntilExit()rejection.Repro:
shopify kitchen-sink async— progress bars remain on screen after completing.See the equivalent change in
ConcurrentOutput.tsxfrom #6831 (269f3aa6).Test plan
Tasks.test.tsx— 13 tests passSingleTask.test.tsx— 11 tests passui.test.ts— 16 tests passrenderSingleTaskerror path works (previously hung indefinitely)shopify kitchen-sink asyncand verify progress bars clear on completion🤖 Generated with Claude Code