Solid reads `0` from `undefined` in the `<Switch>` component
Describe the bug
When using a resource that errors in the when condition of a Match within Switch, Solid will try to write undefined to the memo result. But that fails because the equals function defined in https://github.com/solidjs/solid/blob/main/packages/solid/src/render/flow.ts#L144 tries to access a[0] === b[0] with b being undefined which fails with
TypeError: Cannot read properties of undefined (reading '0')
at Object.equals [as comparator] (esm.sh/v110/[email protected]/es2022/solid-js.development.js:1582:38)
at writeSignal (esm.sh/v110/[email protected]/es2022/solid-js.development.js:703:33)
Your Example Website or App
https://playground.solidjs.com/anonymous/8c7b2f6b-310b-4449-8d07-9b5d200798ec
Steps to Reproduce the Bug or Issue
See playground -
There you can edit the code to have the onError commented out to have different behavior:
- With
onErrorandwhen={resource()}-- only TypeError is seen - With
onErrorandwhen={throws()}-- Thrown error shows twice, TypeError shows once - Without
onErrorandwhen={resource()}-- Only resource error is seen - Without
onErrorandwhen={throws}-- Only Thrown error is seen
Expected behavior
Expected to see it not throwing due to a Solid implementation bug
Screenshots or Videos
No response
Platform
- OS: macOS
- Browser: Chrome
- Version: 1.6.11
Additional context
No response
On 1.6.9 this causes Solids reactivity to go stale and not update at all.
Also fixed by https://github.com/solidjs/solid/commit/b8a3ff131e46bb57837062933dc0e1df63feb054