App builds call the harness's `__rt.reg` for every binding; the registry is never pruned and grows with each mount (CP-4c)

未關閉
#80 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 1 天內回覆

還沒有人認領這個 Issue。

評估

難度
4/5
預估耗時
3-5 天
新手友好度
54/100
Issue 類型
缺陷
描述清晰度
描述清楚
活躍度
活躍
技術堆疊
typescript
領域
build-system

研究方向

Start with spec/11-compiler.md CP-4c and trace compile_linked and the reg emission sites in compiler/src/emit.rs; compare how app builds and conformance builds are selected. Then inspect ref/compile/rt-web.ts and the Vite plugin’s app path. Done means app builds no longer emit harness registry calls, with conformance builds retaining them as specified.

由索引模型根據 Issue 內容生成。

描述

Every module app() compiles (the Vite front end, rxc app) calls the conformance harness's __rt.reg(name, …) for every binding. The runtime's reg appends to a registry that nothing ever removes from, so an app that keeps mounting components grows that registry without bound.

Versions: @reactivescript/compiler, @reactivescript/runtime 0.3.1; solid-js / @solidjs/web 2.0.0-rc.21; @solidjs/vite-plugin 3.0.0-next.57.

Repro

main.rx:

component Row({ label }: { label: string }) {
  upper = label + "!"
  <li>{upper}</li>
}

export default component App() {
  source items := ["a", "b", "c"]
  <ul>{for item in items { <Row label={item} /> }}</ul>
}

Compiled with app("main.rx", "dom"), Row contains:

__rt.reg("label", { get: v$label });
__rt.reg("upper", { get: v$upper });

Mounting it with createApp from @reactivescript/runtime/web, counting calls to app.reg, and replacing items with three new strings 1000 times (app.dset("items", [], [...]) then flush()):

after mount: rows 3 reg calls 7
after 1000 replacements: rows 3 reg calls 6007

The DOM holds three rows at the end, but the registry holds 6007 entries. Each entry keeps the disposed rows' accessors (and through them their nodes) reachable for the life of the app.

Expected

spec/11-compiler.md CP-4c: reg, lookup, dget, dset, api, jsError, B.fetch/B.fail, … are the harness's, and "Compiled code calls them only in a conformance build — the compiler's option for running scenarios/". The app build (app(), the product path the Vite plugin uses) should not emit __rt.reg, or the module-level reg for imports. If a registry stays in the runtime for some other reason, an entry should be removed when its owner is disposed.

Cause

  • The crate has no conformance switch. compile_linked (compiler/src/emit.rs:194) takes only by_source, and the reg statements are emitted unconditionally: compiler/src/emit.rs:696, :739, :761, and fn reg at :893-899, which every source, equation and prop goes through.
  • ref/compile/rt-web.ts:154 (published dist/web.js reg) only ever does l.push(e). There is no onCleanup and no removal.

Related: #74 is another case of harness-only code (the scenario prelude __B.*) reaching app builds.

主要語言
TypeScript
星號
127
分支
7
平均合併
15 小時 42 分鐘
30 天內合併 PR
63

環境準備

  • 沒有 Dockerfile 或 Docker Compose 檔案
  • 沒有 Pull Request 範本
  • 閱讀貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

solidjs/reactivescript 的其他 Issue

查看 solidjs/reactivescript 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。