Skip to content

fix(deps): run on_dependencies() once per instance on interactive pages - #260

Merged
JuroOravec merged 2 commits into
mainfrom
fix/on-dependencies-once
Oct 22, 2026
Merged

JuroOravec merged 2 commits into
mainfrom
fix/on-dependencies-once

Conversation

@JuroOravec

Copy link
Copy Markdown
Member

Summary

On an interactive page (deps_strategy="document"), a component's on_dependencies() ran twice per instance: once when the Vue producer built the app's asset list, and again in emit_dependencies, which threw the second result away. emit_dependencies now skips that second pass when the Vue app already holds the assets, so the hook runs once per instance each time the page is serialized, as documented.

The same sweep found per-call notes left in the root context after a serialize. Serializing the same render again with deps_strategy="simple", after an interactive "document" or "fragment" call, then left out every script and stylesheet. serialize_render_result now clears those notes for the length of each call and restores the previous ones afterwards, so a nested serialize inside an on_serialize hook also leaves the outer page intact.

Tests

  • New tests/test_deps_emission.py cases: the hook runs once per instance; a second "simple" serialize after "document" and "fragment" writes the assets; a nested serialize keeps the outer notes.
  • test_simple_vue_mode.py asserted the stale result (no component script in a second "simple" serialize). It now asserts what a fresh render gives. That test encoded the bug.

Checks run locally

Python phases of scripts/check.py against origin/main's environment: ruff check and format, mypy (also --platform linux), the non-browser pytest suite and the validators. The branch changes no Rust or JS, so the cargo, Node and Vue parity phases are left to CI.

🤖 Generated with Claude Code

JuroOravec and others added 2 commits October 22, 2026 22:15
On an interactive page with deps_strategy="document", the Vue producer
resolves the dependency records while it builds the app's asset list,
running each instance's Component.on_dependencies. emit_dependencies then
resolved the same records again and threw the result away, so the hook
ran twice per instance. emit_dependencies now skips that second pass when
the Vue app already holds the assets, and emits only the runtime.

The same sweep found per-call notes (the "assets already prepared" and
"runtime required/emitted" keys) left in the root context's extra after a
serialize. Serializing the same render again with deps_strategy="simple"
after an interactive document or fragment call then left out every script
and stylesheet. serialize_render_result now clears those notes for the
length of each call and restores the previous ones afterwards, so a
nested serialize inside an extension's on_serialize hook also leaves the
outer page intact.

test_simple_vue_mode asserted the stale-state result (no component script
in a second "simple" serialize); it now asserts what a fresh render gives.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@JuroOravec
JuroOravec merged commit 86d7294 into main Oct 22, 2026
26 of 27 checks passed
@JuroOravec
JuroOravec deleted the fix/on-dependencies-once branch October 22, 2026 20:37
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.

1 participant