Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
mathieuprog opened this issue Oct 2, 2023 · 3 comments · May be fixed by #2227
Open

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

mathieuprog opened this issue Oct 2, 2023 · 3 comments · May be fixed by #2227
Labels
unverified bug Bug yet to be verified

Comments

@mathieuprog
Copy link
Contributor

mathieuprog commented Oct 2, 2023

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.
@ryansolid
Copy link
Member

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 ryansolid added the unverified bug Bug yet to be verified label Oct 5, 2023
@mathieuprog
Copy link
Contributor Author

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.

@gidra5
Copy link

gidra5 commented May 25, 2024

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

@mdynnl mdynnl linked a pull request Jul 18, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
unverified bug Bug yet to be verified
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants