Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Generated client entry runs before the root is parsed (async script in <head>)

已关闭
#411 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
25/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
typescript, vite

调研方向

The injected script tag is generated in src/ssr/index.ts around lines 1387-1391, where the entry is placed before </head> with the async attribute. Read how the plugin chooses between async and deferred output, and check the linked repro's /, /?defer and /stream cases. Done means a fix that hydrates the slow-HTML and streamed pages without making streamed pages wait for their slowest read. Expect a design discussion about the trade-off before code.

由索引模型根据 Issue 内容生成。

描述

@solidjs/vite-plugin 3.0.0-next.49 injects the generated client entry before </head> as <script type="module" async>:
https://github.com/solidjs/solid-vite-plugin/blob/44d90fd7fb8ae6d0efc6a42c82ad2d91adc3658a/src/ssr/index.ts#L1387-L1391

An async module runs as soon as it loads. When the HTML arrives slowly, the entry can run while the browser is still parsing the body. Hydration then reaches nodes that do not exist yet and fails with Cannot read properties of null (reading 'nextSibling') (or 'firstChild'). Nothing after that point hydrates.

Repro: https://stackblitz.com/github/feledori/solid-async-entry-repro

  • /: a long page served at 2 kB per 50 ms. Hydration fails on every load, and the buttons near the end do nothing.
  • /?defer: the same page with async removed. It hydrates every time.
  • /stream: a streamed page with a 3 s <Loading> read. DOMContentLoaded fires when the response ends (~3 s), while the async entry starts hydration at ~100 ms. So waiting for DOMContentLoaded, or dropping async, would make every streamed page wait for its slowest read.
主要语言
TypeScript
星标
522
派生
73
平均合并
1 天 4 小时
30 天内合并 PR
35

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

solidjs/solid-vite-plugin 的其他 Issue

查看 solidjs/solid-vite-plugin 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。