Skip to content

[2.0] Writing to a store outside its setter is silently ignored #4179

Closed

Description

@devagrawal09

Describe the bug

Writing to a store proxy outside setStore does nothing: no write, no error, no dev diagnostic, and no type error.

  • The proxy's set trap returns true without writing outside a draft (packages/signals/src/store/store.ts, if (!draft && !override) return true;). deleteProperty behaves the same way.
  • Store<T> = T (store/types.ts), so TypeScript doesn't flag it either.

Your Example Website or App

Minimal repro inline below (signals-only).

Steps to Reproduce the Bug or Issue

import { createStore, createRoot, createRenderEffect, flush } from "@solidjs/signals";

const [store, setStore] = createStore({ n: 0, items: [] as number[], user: { name: "a" } });
createRoot(() => createRenderEffect(() => store.n, v => console.log("n", v)));
flush();

store.n = 5;
store.items.push(1);
store.user.name = "b";
delete (store as any).user;
flush();
// store.n === 0, store.items.length === 0, store.user.name === "a"
// Nothing throws, nothing is logged, the effect doesn't run.

setStore(s => { s.n = 5; }); flush(); // works: logs "n 5"

Expected behavior

In dev, a direct write should be reported. For example, a STORE_WRITE_OUTSIDE_SETTER diagnostic, emitted once per store path, with the path and a setStore(s => …) hint. Production behavior would stay the same.

Optionally, an opt-in deep-readonly Store<T> type. That's a bigger change, because it affects passing store data to functions that take mutable types.

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 @ b0ad1df (2026-10-20, after 2.0.0-rc.16)

Additional context

Mutating state directly is the default habit for people coming from MobX or Vue, and for coding agents writing Solid. Today the result is a UI that silently doesn't update. Most other "this does nothing" cases in 2.0 have a diagnostic code. This came up while writing and verifying the From React docs additions (solidjs/solid-docs#1664).

— Claude, on behalf of @devagrawal09

Activity

  1. devagrawal09 commented on Oct 21, 2026

    @devagrawal09
    Author

    For context: eslint-plugin-solid's v2 config (0.18.1) already has solid/no-store-mutation-outside-setter as an error. It catches assignments, ++/--, delete and mutating array methods (push, splice, …) on a store's read proxy. So linted code is covered, at least when the store comes from a createStore(...) call the rule can see. As far as I can tell from the source, the rule identifies stores from their declarations in the same file.

    That narrows this issue to a runtime dev diagnostic for what lint can't see:

    • stores passed through props, context or function arguments;
    • projects that don't use the plugin;
    • generated code that runs before anyone lints it.

    — Claude, on behalf of @devagrawal09

  2. ryansolid commented on Oct 21, 2026

    @ryansolid
    Member

    Fixed in #4194, merged to next as a99550e. It will ship in the next RC.

    — Claude via Claude Code


    Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions