Skip to content

fix(vtz): recover from wiped .vertz/deps/ and clear stale dep re-bundle errors [#2954]#2995

Merged
viniciusdacal merged 2 commits intomainfrom
fix/dep-rebundle-stale-errors
Apr 24, 2026
Merged

fix(vtz): recover from wiped .vertz/deps/ and clear stale dep re-bundle errors [#2954]#2995
viniciusdacal merged 2 commits intomainfrom
fix/dep-rebundle-stale-errors

Conversation

@viniciusdacal
Copy link
Copy Markdown
Contributor

Summary

Closes #2954. Two compounding bugs in the dev-server dep-watcher path caused a cluster of Failed to re-bundle upstream dep X: Failed to write entry file: No such file or directory (os error 2) errors to survive forever in the /__vertz_errors overlay — even though the app SSRed fine. The only cure was killing the dev server, deleting .vertz/dev/errors.json, and restarting.

  • Bug 1native/vtz/src/deps/prebundle.rs: prebundle_single now create_dir_all(deps_dir) before writing the temporary entry file, so a wiped or missing .vertz/deps/ no longer surfaces as ENOENT when the dep watcher triggers a re-bundle.
  • Bug 2native/vtz/src/watcher/dep_watcher.rs + server/http.rs: the dep-watcher handler now tags every re-bundle error with a synthetic per-package key (<dep>:{pkg}) in the error's file field, and clear_file(ErrorCategory::Build, …) each package it touches this cycle before reporting the current failure. Stale entries no longer linger in ErrorState / .vertz/dev/errors.json.

Why targeted (not clear_category)

An adversarial review blocked the first attempt (clear_category(Build) on any successful rebundle): the module server and file-change handler report user-source compile errors under the same Build category, so clobbering the whole category on every successful rebundle would make real compile errors vanish from the overlay. The per-key clear avoids that, and is covered by test_apply_dep_error_state_preserves_user_compile_errors.

Public API Changes

  • None. apply_dep_error_state and dep_error_file are new public items in the internal vtz crate; they are not part of any SDK/library surface.

Test plan

  • cargo test --all (TDD — RED verified on both fixes before GREEN)
  • cargo clippy --all-targets -- -D warnings
  • cargo fmt --all -- --check
  • New regression tests:
    • test_prebundle_single_recreates_missing_deps_dir
    • test_apply_dep_error_state_clears_stale_build_errors_on_success
    • test_apply_dep_error_state_preserves_user_compile_errors (B1 review blocker)
    • test_apply_dep_error_state_reports_new_failures
    • test_apply_dep_error_state_mixed_success_and_failure
    • test_apply_dep_error_state_all_failures_replace_stale_for_same_packages
  • Changeset added (@vertz/runtime, patch)

🤖 Generated with Claude Code

viniciusdacal and others added 2 commits April 24, 2026 11:03
…le errors [#2954]

Two compounding bugs on the dev-server dep-watcher path caused a cluster
of "Failed to re-bundle upstream dep X: Failed to write entry file: No
such file or directory (os error 2)" errors to survive forever in the
error overlay, even though the app SSRed fine.

1. `prebundle_single` now `create_dir_all(deps_dir)` before writing its
   temporary entry file, so a wiped or missing `.vertz/deps/` no longer
   bubbles up as ENOENT when the dep watcher triggers a re-bundle.

2. The dep-watcher handler in `server::http` clears the `Build` error
   category whenever at least one package re-bundles successfully,
   before reporting the current cycle's failures. Stale dep-rebundle
   entries no longer accumulate in `ErrorState` (or the persisted
   `.vertz/dev/errors.json`) across cycles. The error-broadcast side
   effects were extracted into `watcher::dep_watcher::apply_dep_error_state`
   so the behavior is covered by regression tests without spinning up a
   full dev server.

Closes #2954

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Adversarial review surfaced that the previous commit's
`clear_category(ErrorCategory::Build)` on a successful rebundle would
also wipe legitimate per-file user-source compile errors, which the
module server and file-change handler report under the same `Build`
category.

Tag every dep-rebundle error with a synthetic key
`<dep>:{package}` in the error's file field, and only clear that key
with `clear_file(ErrorCategory::Build, …)` for each package the current
cycle touches. Stale dep errors still disappear after a successful
rebundle, but file-scoped compile errors from user source code are now
left untouched.

Add `test_apply_dep_error_state_preserves_user_compile_errors` to
regress this exact case.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@viniciusdacal viniciusdacal merged commit 212fa91 into main Apr 24, 2026
7 checks passed
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.

vtz dev: 'Failed to re-bundle upstream dep' overlay survives forever — two compounding bugs in the dep re-bundle path

1 participant