Solid: 0.17 occasionally breaks list rendering

Created on 25 Mar 2020  路  5Comments  路  Source: ryansolid/solid

The script then fails with a Type error: n is undefined in this line.

The issue seems to be that sometimes source.observers is a sparse array with a .length greater than the actual length, allowing .pop() to return undefined.

Unfortunately I am not able to provide a simple example where this occurs, but there are apps that break when updating to version 0.17.

bug

All 5 comments

Thanks for reporting. I tried to test in every scenario I had but this release saw a rewrite of the reactive core. I will investigate. The observers array should always be push and pop but maybe there is a bug in how items are moved in cleanup. Obviously any more details are helpful but I will investigate none the less.

My observation was that including the following check for sparseness after line 347, will only trigger immediately before and when failing:

if (source.observers.length !== source.observers.filter(Boolean).length) {
  console.log(Array.from(source.observers));
}

Screenshot 2020-03-25 at 16 26 43

Edit

The following check also only triggers before failing:

if (index > source.observers.length) {
  console.log('index too high');
}

Thanks I downloaded your app and found an easy to reproduce scenario with the subscribe button. Your last hint is helpful. I see it happening now just trying to figure out how the indexes are getting out of sync.

Ok update. I know what the problem is just deciding on the right fix. Logic was too simple to handle duplicate nodes in the list. In practice checking uniqueness all the time is more expensive than just adding deps that will never run anyway, but obviously if the disposal logic can't handle it we have a problem.

Seems almost too simple of a fix but I realized it is what the old version was doing. Checking node equality was just messing things up. Fixed in 0.17.1. Reopen if it's still an issue. I was only able to verify the one case and while conceptually this should have fixed everything its always possible to miss something.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ajihyf picture ajihyf  路  6Comments

Ziriax picture Ziriax  路  4Comments

kavsingh picture kavsingh  路  4Comments

aguilera51284 picture aguilera51284  路  7Comments

Yakulu picture Yakulu  路  4Comments