solid icon indicating copy to clipboard operation
solid copied to clipboard

Uncaught TypeError: evalConditions is not a function or its return value is not iterable

Open mathieuprog opened this issue 1 year ago • 3 comments

Describe the bug

I started to have this cryptic error message when starting my app:

Uncaught TypeError: evalConditions is not a function or its return value is not iterable at Switch.createMemo.name [as fn] (dev.js:1517:33) at runComputation (dev.js:691:22) at updateComputation (dev.js:674:3) at Object.readSignal (dev.js:607:67) at resolveChildren (dev.js:983:82) at resolveChildren (dev.js:983:66) at createMemo.name [as fn] (dev.js:573:33) at runComputation (dev.js:691:22) at updateComputation (dev.js:674:3) at createMemo (dev.js:251:10)

There is no indication of the problem in my code or the line that causes this error.

Platform

  • OS: Windows
  • Browser: Chrome 117
  • SolidJS: 1.7.12

Update:

The cause seems to be this line:

<Match when={!currentUser.latest && currentUser.loading}>

If I remove the condition !currentUser.latest (or !currentUser()), the error disappears. Basically what I am trying to match on is: "the current user is loading for the first time (i.e. has not been previously fetched)"

So there are 2 issues:

  1. cryptic error message (had to remove one by one every Match in different Switch elements to see which caused the error);
  2. I don't see why I can't check if the resource value is undefined or has been previously fetched in a Match.

mathieuprog avatar Oct 02 '23 09:10 mathieuprog

Yeah this seems like an odd Transition or Suspense issue. Without a reproduction it might be harder to determine the cause exactly. latest does bypass Suspense which makes me think so. The thing is the error is coming form switch match which always returns an array... but initial value doesn't have one, which could be where it is choking. It should run it once but if there is something odd going on we might have our issue.

ryansolid avatar Oct 04 '23 04:10 ryansolid

I switched to using Show to match on this condition. I tried to reproduce using the playground but can't, the real-world case also involves routing and other features - it is hard to replicate the case in the playground.

mathieuprog avatar Oct 22 '23 13:10 mathieuprog

I stumbled upon the same error message today, and figured out minimal reproduction. Basically whenever condition computation throws switch will fail with this error. For me exact issue was accessing field on undefined, which was obscured by this error. When I removed switches as was suggested, I was able to see it. Take a look at playground below. Although error is from minified code, which obscures it, I verified locally that its the same error.

https://playground.solidjs.com/anonymous/114a9167-60c3-464d-8dbe-b5ef2ca2a8ea

gidra5 avatar May 25 '24 19:05 gidra5