Repository navigation
Closed
Labels
Bug: ValidatedThis PR or Issue is verified to be a bug within Stencil
Description
Prerequisites
- I have read the Contributing Guidelines.
- I agree to follow the Code of Conduct.
- I have searched for existing issues that already report this problem, without success.
Stencil Version
4.19.0
Current Behavior
Hydrate crashes if a full document is hydrated with serializeShadowRoot: false
unhandledRejection Error: referenceNode not found in parentNode.childNodes
at insertBefore (C:\dev\ssr-stencil-test\dsd-ssr\hydrate\index.js:13860:15)
at _MockDocument.insertBefore (C:\dev\ssr-stencil-test\dsd-ssr\hydrate\index.js:13071:7)
at addStyle (C:\dev\ssr-stencil-test\dsd-ssr\hydrate\index.js:548:30)
at attachStyles (C:\dev\ssr-stencil-test\dsd-ssr\hydrate\index.js:566:20)
at updateComponent (C:\dev\ssr-stencil-test\dsd-ssr\hydrate\index.js:1175:5)
at C:\dev\ssr-stencil-test\dsd-ssr\hydrate\index.js:1162:38
at enqueue (C:\dev\ssr-stencil-test\dsd-ssr\hydrate\index.js:1167:6)
at dispatchHooks (C:\dev\ssr-stencil-test\dsd-ssr\hydrate\index.js:1162:10)
at dispatch (C:\dev\ssr-stencil-test\dsd-ssr\hydrate\index.js:1136:26)
at C:\dev\ssr-stencil-test\dsd-ssr\hydrate\index.js:2039:7
This only happens if a <link ... > tag is inside the <head>
Happens inside the addStyle() -> insertBefore() method (see trace).
Expected Behavior
No crashes.
System Info
No response
Steps to Reproduce
- See repo, set
serializeShadowRoottofalseinserver.js.
Code Reproduction URL
Additional Information
server.js
const html = await hydrate.renderToString(
`<html>
<head>
<link rel="stylesheet" href="whatever.css" >
</head>
<body>
<div class="__next">
<main>
<my-component last-page="5"></my-component>
<my-whatever-component>abc</my-whatever-component>
<div class="my-5">
<my-other-component label="2"></my-other-component>
</div>
<my-component last-page="2"></my-component>
</main>
</div>
<script type="module">
import { defineCustomElements } from "./static/loader/index.js";
defineCustomElements().catch(console.error);
</script>
</body>
</html>`,
{ fullDocument: true, serializeShadowRoot: false },
);Metadata
Metadata
Assignees
Labels
Bug: ValidatedThis PR or Issue is verified to be a bug within Stencil
Activity
christian-bromann commentedon Jul 1, 2024
This should get resolved with #5876 which is currently being reviewed. You can use
@stencil/[email protected]which is a dev release that contains this fix.ptmkenny commentedon Jul 1, 2024
Since the Ionic starter apps have a
<link>inside<head>, it would be great if there was an automated test against the starter apps to catch issues like this.christian-bromann commentedon Jul 1, 2024
@ptmkenny thanks for the feedback @ptmkenny! We will evaluate this with the framework and Stencil team whether this is feasible for us as it requires running these starter apps with a custom compiled Ionic Framework version that uses a custom compiled Stencil version. Overall we have much better test coverage for these edge cases now which makes it less likely that these bugs happen again.
christian-bromann commentedon Jul 17, 2024
Closing as this has been resolved and was released with the last Stencil version.