Skip to content

fix(hooks): add unmount cleanup to useBatchCreate - #335

Merged
Austinaminu2 merged 1 commit into
FlowwStar:mainfrom
coredevdave-cmd:fix/issue-274-batch-create-unmount-cleanup
Jul 25, 2026
Merged

fix(hooks): add unmount cleanup to useBatchCreate#335
Austinaminu2 merged 1 commit into
FlowwStar:mainfrom
coredevdave-cmd:fix/issue-274-batch-create-unmount-cleanup

Conversation

@coredevdave-cmd

Copy link
Copy Markdown

Summary

  • useBatchCreate started batch stream creation but had no cleanup on unmount, so the running batch continued posting setProgress updates to an already-unmounted component
  • Add a useEffect with a cleanup function that sets abortRef.current = true on unmount — the same flag already checked at the top of every loop iteration in both createBatch and retryFailed
  • Import useEffect from React (was not previously imported)

The cleanup mirrors what the existing cancel() callback does, making unmount behaviour automatic rather than relying on callers to call cancel() before the component unmounts.

Test plan

  • Mount a component that uses useBatchCreate and starts a long batch; unmount it mid-batch; confirm no React setState warnings appear in the console
  • Confirm that cancel() still works as before for explicit early termination
  • Confirm the completed-batch happy path is unaffected

Closes #274

useBatchCreate started a batch operation but had no cleanup on unmount,
so the running batch would continue posting state updates to an already-
unmounted component. Add a useEffect that sets abortRef.current = true
on cleanup, mirroring what the existing cancel() callback does. The
abortRef flag is already checked at the top of every loop iteration in
both createBatch and retryFailed, so setting it on unmount is sufficient
to stop any in-progress batch without further changes.

Closes FlowwStar#274
@drips-wave

drips-wave Bot commented Jul 25, 2026

Copy link
Copy Markdown

@coredevdave-cmd Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: use-batch-create has no unmount cleanup — batch keeps running after navigating away

3 participants