Skip to content

2.0.0-rc.3 | latest() does not work on projected value createProjection() #3075

Closed

Description

@mizulu

Describe the bug

latest on projected signal does not work, shows uncommitted value

Your Example Website or App

https://s.olid.uk/id/sAPh460QTq-eozQTHk06Qg

Steps to Reproduce the Bug or Issue

playground

Expected behavior

latest on projected value createProjection should work like it works for derived signal or memo

Screenshots or Videos

No response

Platform

.

Additional context

broken since 2.0.0-rc1, but works in 2.0.0-rc.0

import { render, untrack, memo } from '@solidjs/web';
import { createSignal, createProjection,  latest, createMemo } from 'solid-js';

export default function App() {
  const [count, setCount] = createSignal(0);

  const [derived, setDerived] = createSignal(()=>{
    return count()
  })

  const m = createMemo(()=>{
    return count()
  })



  const p = createProjection(() => {
    return { a: count() }
  }, {})



  setTimeout(() => {
    untrack(() => {

      setCount(v => v + 5)
    
      console.log("count", count(), latest(count)) // 0 5  latest on source   (success)
      console.log("p.a", p.a, latest(()=>p.a))     // 0 0  latest on projected count  (Fail)
      console.log(derived(), latest(derived))     // 0 5   latest on derived signal (success)
      console.log(m(), latest(m))                 // 0 5   latest on memo  signal (success)

    })
  })



  return (
    <div class="p-2">
     latest does not work for projection, but works for derived signal, or memo
    </div>
  );
}


if (typeof document !== 'undefined') {
  render(() => <App />, document.getElementById('root')!);
}

``

Activity

  1. ryansolid commented on Aug 27, 2026

    @ryansolid
    Member

    Fixed in 0e37f90 (same commit as #3074 — two directions of one isolation gap).

    Why it never worked: latest() is implemented in core read(), which routes the read through a companion computed that re-evaluates speculatively against pending values — that's what makes it work for signals, memos, and derived signals. But store property reads go through the proxy traps, which only reach core read() when there's a tracking observer; an untracked latest(() => p.a) served the committed backing straight from the trap, so the latest window was invisible to stores. (The rc.0 → rc.1 regression window you bisected is the store rewrite — the legacy store happened to route these reads through core.)

    Now the get trap recognizes the latest window: it pulls the projection computed up to date first (so the derive re-runs against the in-flight source values), then serves the in-flight derivation. The speculative recompute this triggers is staged, not committed — a plain p.a read right after still shows the committed value until flush(), matching count() vs latest(count) exactly.

    Your playground's four log lines now all pair up: count 0 5, p.a 0 5, derived 0 5, memo 0 5.

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