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 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
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分
マージ済み PR(30日)
63

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

solidjs/reactivescript のほかの issue

solidjs/reactivescript の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。