Skip to content
Source
Sign inSign up
TanStack/cli

fix(cli): finish pending writes before dev watch shutdown #563

Mergedtannerlinsleymerged 1 commit intomain fromrefs/pull/563/headmerged by tannerlinsley

tannerlinsleycommented

Dev watch now waits for in-flight writes before removing its temporary directory. It cancels pending package-manager commands and skips syncing an interrupted rebuild. CLI and core are versioned together because the CLI uses core's new cancellation argument.

The strengthened shutdown fixture failed against the old code and passed with this fix. The normal hook passed all builds, unit tests, and eight Chrome tests. A separate local subprocess check confirmed cancellation.

Summary by CodeRabbit

  • Bug Fixes
    • Improved development-watch shutdown reliability: pending rebuild writes are allowed to finish before temporary files are cleaned up.
    • Prevented new rebuilds from starting while shutdown is underway or another build is active.
    1. 🦋 Changeset detected

      Latest commit: 0120a70bc286439bffad751f0c2028695aedcab0

      The changes in this PR will be included in the next version bump.

      This PR includes changesets to release 7 packages
      NameType
      @tanstack/cliPatch
      @tanstack/createPatch
      create-start-appPatch
      create-tanstack-appPatch
      create-tanstackPatch
      create-tsrouter-appPatch
      @tanstack/create-startPatch

      Not sure what this means? Click here to learn what changesets are.

      Click here if you're a maintainer who wants to add another changeset to this PR

    2. coderabbitai[bot](GitHub profile, opens in a new tab)commented
      Explain Change →

      No actionable comments were generated in the recent review.

      Walkthrough

      Dev-watch now passes a shutdown signal to rebuild commands and waits for an active rebuild before cleanup. The rebuild fixture tests shutdown during a temporary-directory write. A changeset marks @tanstack/cli and @tanstack/create for patch releases.

      Changes: Dev-watch rebuild shutdown

      Layer / File(s)Summary
      Abortable rebuild environment
      packages/create/src/environment.ts, packages/cli/src/dev-watch.ts
      createDefaultEnvironment accepts an optional AbortSignal and passes it to package-manager commands. Dev-watch uses this environment for rebuilds and skips synchronization if shutdown has started.
      Shutdown and active-build drain
      packages/cli/src/dev-watch.ts, packages/cli/tests/fixtures/dev-watch-rebuild.mjs, .changeset/dev-watch-drain.md
      Dev-watch tracks active builds, blocks new builds during shutdown, and waits for the active build before cleanup. The fixture tests shutdown during a temporary-directory write. The changeset records patch releases for both packages.

      Estimated code review effort: 3 (Moderate) | ~20 minutes

      Change: Bug fix

      Sequence Diagram(s)

      sequenceDiagram
        participant SignalHandler
        participant DevWatchManager
        participant AbortController
        participant Watcher
        participant Rebuild
        participant Cleanup
        SignalHandler->>DevWatchManager: stop()
        DevWatchManager->>AbortController: abort rebuild signal
        DevWatchManager->>Watcher: close watcher
        DevWatchManager->>Rebuild: await active build
        Rebuild-->>DevWatchManager: build completes
        DevWatchManager->>Cleanup: clean up

      Suggested reviewers: 43081j

      Merge Risk: Minimal · up to 0120a

      Dev-watch shutdown now waits for in-flight rebuild writes and cancels pending commands before removing its temporary directory. No actionable merge-blocking risk remains.

      Pre-merge checks: Passed 5
      Check nameStatusExplanation
      Description CheckPassedCheck skipped - CodeRabbit’s high-level summary is enabled.
      Title checkPassedThe title "fix(cli): finish pending writes before dev watch shutdown" matches the main change. The dev-watch.ts shutdown now waits for the active build, and the rebuild write to the temporary director…
      Docstring CoveragePassedNo eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
      Linked Issues checkPassedCheck skipped because no linked issues were found for this pull request.
      Out of Scope Changes checkPassedCheck skipped because no linked issues were found for this pull request.
      Full details: Title check

      Explanation

      The title "fix(cli): finish pending writes before dev watch shutdown" matches the main change. The dev-watch.ts shutdown now waits for the active build, and the rebuild write to the temporary directory finishes before cleanup removes it. The title names the CLI scope and the fix. It omits the related cancellation of package-manager commands in core, which is a secondary aspect of the change.

      Full details: Docstring Coverage

      Explanation

      No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 0 functions across 3 files. (1 skipped: 1 unsupported.)

      Finishing Touches
      Generate docstrings
      • Commit to this branch
      • Create a new PR
      Generate unit tests (beta)
      • Commit to this branch
      • Create a new PR
      • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

      Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

      Share
      Recent review info
      Run configuration
      • Source mode: Auto
      • Repository: Unavailable
      • Branch: Unavailable
      • File: No configuration file from this repository applied
      • Commit: Unavailable
      • Layers: defaults
      • Review profile: CHILL
      • Plan: Advanced
      • Run ID: f1f6be09-a6b7-4f12-bdbc-ad2acc15aaae
      Commits

      Reviewing files that changed from the base of the PR and between 6d6116b98eb134558abaff8849e120a12714b596 and 0120a70bc286439bffad751f0c2028695aedcab0.

      Files selected for processing: 4
      • .changeset/dev-watch-drain.md
      • packages/cli/src/dev-watch.ts
      • packages/cli/tests/fixtures/dev-watch-rebuild.mjs
      • packages/create/src/environment.ts

      Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 2 remain after this review.

    3. tannerlinsley merged this81d3e99

    4. tannerlinsley closed this

Sign in to join this conversation.