Repository navigation
fix(deps): run on_dependencies() once per instance on interactive pages - #260
Merged
Merged
Conversation
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]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
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
On an interactive page (
deps_strategy="document"), a component'son_dependencies()ran twice per instance: once when the Vue producer built the app's asset list, and again inemit_dependencies, which threw the second result away.emit_dependenciesnow 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_resultnow clears those notes for the length of each call and restores the previous ones afterwards, so a nested serialize inside anon_serializehook also leaves the outer page intact.Tests
tests/test_deps_emission.pycases: 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.pyasserted 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.pyagainstorigin/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