Astro Info
<paste output of `astro info` here>
## If this issue only occurs in one browser, which browser is a problem?
N/A (server/runtime emission logic)
If this issue only occurs in one browser, which browser is a problem?
No response
Describe the Bug
There appears to be a shared bug pattern in Astro SSR script/runtime dedup logic: global "already rendered" flags are committed before confirming the script/runtime is being emitted into executable DOM context.
From current main source inspection, these paths still look context-blind at the point state is flipped:
determineIfNeedsHydrationScript() in packages/astro/src/runtime/server/scripts.ts
determinesIfNeedsDirectiveScript() in packages/astro/src/runtime/server/scripts.ts
rendererSpecificHydrationScripts dedup path in packages/astro/src/runtime/server/render/common.ts
hasRenderedServerIslandRuntime in packages/astro/src/runtime/server/render/common.ts
Because dedup is toggled globally at first encounter, a first hit inside an inert/non-executable context can prevent required script/runtime output in a later executable placement.
What's the expected result?
Dedup state should only be committed once Astro confirms the script/runtime is emitted into an executable DOM context (or dedup should be scoped per effective render context), so later valid placements are not incorrectly skipped.
In other words:
- encountering a hydration/directive/island runtime path in an inert location should not consume the global "already rendered" state
- a subsequent executable location should still emit the required script/runtime exactly once
Link to Minimal Reproducible Example
https://stackblitz.com/edit/github-9p8z3w1k?file=README.md
(Replace with your real minimal repro before filing. If useful, I can draft a concrete repro layout for this issue.)
Participation
Link to Minimal Reproducible Example
safdasdf
Participation
Astro Info
If this issue only occurs in one browser, which browser is a problem?
No response
Describe the Bug
There appears to be a shared bug pattern in Astro SSR script/runtime dedup logic: global "already rendered" flags are committed before confirming the script/runtime is being emitted into executable DOM context.
From current
mainsource inspection, these paths still look context-blind at the point state is flipped:determineIfNeedsHydrationScript()inpackages/astro/src/runtime/server/scripts.tsdeterminesIfNeedsDirectiveScript()inpackages/astro/src/runtime/server/scripts.tsrendererSpecificHydrationScriptsdedup path inpackages/astro/src/runtime/server/render/common.tshasRenderedServerIslandRuntimeinpackages/astro/src/runtime/server/render/common.tsBecause dedup is toggled globally at first encounter, a first hit inside an inert/non-executable context can prevent required script/runtime output in a later executable placement.
What's the expected result?
Dedup state should only be committed once Astro confirms the script/runtime is emitted into an executable DOM context (or dedup should be scoped per effective render context), so later valid placements are not incorrectly skipped.
In other words:
Link to Minimal Reproducible Example
https://stackblitz.com/edit/github-9p8z3w1k?file=README.md
(Replace with your real minimal repro before filing. If useful, I can draft a concrete repro layout for this issue.)
Participation
Link to Minimal Reproducible Example
safdasdf
Participation