Optimistic writes disappear on rows retained from a derived store's draft
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 70/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- typescript
- Domain
- frontend
Research direction
Start by examining the store implementation, focusing on how writable derived stores retain rows from drafts and how createOptimisticStore applies updates. Look at the regression tests for #3767 to understand the expected behavior for ordinary writes, then add a similar test case for optimistic writes. The fix should ensure optimistic updates correctly modify retained rows, possibly by copying them as described in the workaround.
Written by the indexing model from the issue text.
Description
Describe the bug
A writable derived store retains a local row across a source refresh:
const [local, setLocal] = createStore<Row[]>(
draft => [...source(), ...draft.filter(row => row.id === "local")],
[],
);
const [view, setView] = createOptimisticStore(local);
After the refresh, an action optimistically sets the retained row's value to 1 and waits two seconds. The optimistic view keeps showing 0 throughout the action.
There are no concurrent actions or pending source updates; the setup updates finish before the action starts.
Your Example Website or App
https://s.olid.uk/id/zG2yQHbUQPa-SyUMiPm_pg
Steps to Reproduce the Bug or Issue
- Open the playground.
- Click Run once. The button creates a local row, refreshes the source, then starts the optimistic action, with 100 ms delays between setup updates.
- Observe that Local value stays at
0during the two-second action.
Expected behavior
The optimistic view should show Local value: 1 while the action is pending, then revert to 0 when the action finishes without persisting the change.
Screenshots or Videos
No response
Platform
- OS: Linux
- Browser: Chromium 153.0.8010.12
- Solid: published preview
mizulu/solid2@5c2174c
Additional context
Returning a copy of the retained row (draft.filter(...).map(row => ({ ...row }))) makes the optimistic update appear and revert as expected. Both variants were tested in the browser.
The retained-draft-row pattern is already covered for ordinary writes by the regression tests for #3767. This report concerns optimistic writes over that store.
The playground has Tailwind disabled.
- Dominant language
- TypeScript
- Stars
- 36.1k
- Forks
- 1.1k
- Avg merge
- 13h 13m
- Merged PRs (30d)
- 306
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from solidjs/solid
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 55/100
Maintainers usually reply within 1 day
-
Difficulty 3/5 Half a day Newbie friendliness 65/100
Maintainers usually reply within 1 day
-
Per-scope takeover for live nodes whose server value is still streaming (D8 follow-up to #3817)Open
Difficulty 4/5 3-5 days Newbie friendliness 45/100
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
Maintainers usually reply within 1 day
Similar issues
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
Small-tailqwq/dsh-deep-whale#187 ·
Maintainers usually reply within 1 day
-
Tela Marca manda conferir o campo "Razão social", que em Portugal se chama "Denominação social"Open
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
melgarafael/DeskcommCRM#2503 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
0x80/isolate-package#218 ·
-
bug via-triage
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
pingdotgg/t3code#16859 · 1 comment ·
Maintainers usually reply within 1 day
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
Maintainers usually reply within 1 day