Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

`UNSTABLE_MEMO_OUTPUT` fires on the memo `merge()` creates for a function source (`<C {...cond() ? { a } : {}} />`); its advice (`equals`) cannot be applied to that memo

クローズ
#4,256 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

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

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

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
56/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
javascript, typescript

調査の方向性

Start with the function-source handling in packages/signals/src/store/utils.ts near line 994, then trace how MergeView reads the memo and how checkUnstableOutput reports it in packages/signals/src/core/attribution.ts. Reproduce with the supplied conditional spread and compare the suggested equality behavior with the listed controls. Done means the diagnostic is suppressed or actionable for this internal memo, with the supplied repro and controls behaving as described.

索引モデルが issue の本文から書いたものです。

説明

Versions: solid-js / @solidjs/web / @solidjs/signals / @solidjs/diagnostics 2.0.0-rc.18 (compiler: @solidjs/compiler 2.0.0-rc.18). Reproduces in dev with attribution enabled.

What happens

A component spread whose expression is not a plain object compiles to mergeProps(fn):

// <Child {...(on() ? { tone: 'info' } : {})} />
_$createComponent(Child, _$mergeProps(() => { return on() ? { tone: "info" } : {}; }));

merge() wraps every function source in a bare memo (packages/signals/src/store/utils.ts:994,
flattened[n] = createMemo(s as () => any)), so the memo is created with no options and gets Object.is equality.
The idiom (conditional spread, {...props.rest ?? {}}, {...pick(x)}) returns a fresh object on every run, so
once the source changes four times the attribution engine reports:

[UNSTABLE_MEMO_OUTPUT] memo "computed" produced a new-but-equivalent object on 4 consecutive runs — its equality gate never closes,
so every subscriber re-runs on every upstream change. Return stable references or pass an `equals` option.

(packages/signals/src/core/attribution.ts:1776-1815, message at 1797-1800.)

The user did not write that memo and cannot reach its options; the name is the anonymous "computed". The only
non-obvious way out is to hoist the expression into an own createMemo(..., { equals }) and spread that, which neither
the message nor the diagnostics page (documentation/solid-2.0/08-dev-diagnostics.md, UNSTABLE_MEMO_OUTPUT) says.

Subscribers are real: every props.x read through the merge view subscribes to this memo (utils.ts MergeView SOURCE_MEMO read), so a
new-but-equal object re-runs every prop reader, though no key changed.

Minimal repro

Standalone project: bun add [email protected] @solidjs/[email protected] @solidjs/[email protected] @solidjs/vite-plugin vitest jsdom @testing-library/jest-dom
with the solid vite plugin and environment: 'jsdom'.

import { captureArtifact } from '@solidjs/diagnostics'
import { createSignal, flush } from 'solid-js'
import { render } from '@solidjs/web'

function Child(props: { tone?: string }) { return <p>{props.tone}</p> }

const [n, setN] = createSignal(0)
const { artifact } = await captureArtifact(() => {
  render(() => <Child {...(n() >= 0 ? { tone: 'info' } : {})} />, document.createElement('div'))
  flush()
  for (let i = 1; i <= 8; i++) { setN(i); flush() }
}, { scenario: 'unstable-spread' })

console.log(artifact.diagnostics.filter((d) => d.code === 'UNSTABLE_MEMO_OUTPUT').map((d) => d.message))
// -> one UNSTABLE_MEMO_OUTPUT for memo "computed"

Controls (same harness): <p {...(n() >= 0 ? { title: 'info' } : {})} /> (element spread, no merge memo) is silent;
const props = createMemo(() => ..., { equals: shallow }); <Child {...props()} /> is silent.

Expected

Either no diagnostic for a memo the user cannot configure, or a way to satisfy it.

Suggested fix (any of)

  1. Give the merge() function-source memo a shallow equals for plain objects. A source is only ever consumed as a key bag (MergeView reads keys and values), so two bags with identical own keys and Object.is-equal values are indistinguishable to readers. Verified locally by changing the single line to
    createMemo(s, { equals: shallowPlainEqual }): the repro goes silent, the own-memo control stays silent. (Caveat: compare only Object.getPrototypeOf(x) === Object.prototype; leave stores/proxies/class instances on Object.is.)
  2. Skip checkUnstableOutput for memos created by merge() (flag them internal; _internal exists in dev) and give them a name such as mergeProps.
  3. At minimum, make the message actionable for this case ("if this memo comes from a spread, hoist the expression into createMemo(..., { equals })") and mention it on the diagnostics page.

No duplicate found (gh issue list -R solidjs/solid --search for UNSTABLE_MEMO_OUTPUT, "new-but-equivalent", "merge function source memo equals", "conditional spread props memo"): nothing relevant. Related only: #3325 (spread reads merge proxy through sources, merged).

Verified: the suggested option 1 applied to the installed dev build locally makes all three tests pass; the original was restored afterwards.

主要言語
TypeScript
スター
36.2k
フォーク
1.1k
平均マージ
11時間 19分
マージ済み PR(30日)
337

環境構築

はじめの一歩

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

solidjs/solid のほかの issue

solidjs/solid の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

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

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