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

[2.0] Effects re-run (and run cleanup) when the compute returns an equal value; there's no `equals` option

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

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

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

调研方向

Start with packages/signals/src/signals.ts and inspect EffectOptions, createEffect, and createRenderEffect; the report says an equals option is currently ignored and gives a signals-only reproduction. Run that reproduction or add a focused test for repeated equal compute results, including cleanup counts. Done means the chosen behavior is implemented and verified, or the reactivity documentation clearly explains the current behavior and memo workaround.

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

描述

Describe the bug

createEffect(compute, effectFn) and createRenderEffect re-run the effect function, and the previous cleanup, every time a tracked read changes, even when compute returns the same value as before. EffectOptions (packages/signals/src/signals.ts) has no equals, and passing one is silently ignored.

Your Example Website or App

Minimal repro inline below (signals-only). Real-world occurrence: https://github.com/openclaw/openclaw/blob/1989e3dc436/.agents/skills/solid/references/lessons.md#L8

Steps to Reproduce the Bug or Issue
import { createSignal, createRoot, createEffect, createMemo, flush } from "@solidjs/signals";

let applies = 0, cleanups = 0;
const [n, setN] = createSignal(1);
createRoot(() => createEffect(() => n() > 0, () => { applies++; return () => { cleanups++; }; }));
flush(); setN(2); flush(); setN(3); flush();
// compute returned true three times
Setup computes applies cleanups
Plain 3 3 2
createMemo(() => n() > 0) in front 1 0
{ equals: (a, b) => a === b } passed as options 3 (ignored)

createRenderEffect gives the same numbers.

Expected behavior

Either:

  • the effect skips its apply and cleanup when the compute result is equal (using the same default equals as memos, or an equals option on effects); or
  • the reactivity docs and cheatsheet state the current behavior clearly and recommend a memo in front. An unknown equals option could also warn in dev instead of being silently ignored.
Screenshots or Videos

No response

Platform
  • OS: macOS (Darwin 25.5)
  • Browser: n/a (reproduced in Node v24.18.0 with vitest, importing source)
  • Version: solid next @ b0ad1df50 (2026-10-20, after 2.0.0-rc.16)
Additional context
  • React developers assume the opposite: useEffect skips when its dependencies are unchanged.
  • Cleanups churn: because cleanups re-run, subscriptions and timers are torn down and restarted on unrelated changes.
  • Seen in production: OpenClaw hit this in production. A props refresh re-ran an effect with an unchanged status, which cancelled a timer and never restarted it (https://github.com/openclaw/openclaw/blob/1989e3dc436/.agents/skills/solid/references/lessons.md#L8).
  • Documented as a pitfall: the From React additions (solidjs/solid-docs#1664) describe this.
主要语言
TypeScript
星标
36.1k
派生
1.1k
平均合并
11 小时 17 分钟
30 天内合并 PR
371

环境准备

从这里开始

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

solidjs/solid 的其他 Issue

查看 solidjs/solid 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

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