Why limit maximum number of updates to 1e6 ("Potential Infinite Loop Detected"-Exception)? #2586
-
|
The number of updates is limited to 1e6. This can be seen in the writeSignal-Function: if (Updates.length > 10e5) {
Updates = [];
if (IS_DEV) throw new Error("Potential Infinite Loop Detected.");
throw new Error();
}I understand, that the limitation is there to detect infinite loops, but why does it have to delete all updates and throw an error. After all solidJS cannot know, if there is a real loop or if the application is just huge (thus the naming "potential loop"). Why not simply warn the user using the console? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
@userNotFoundByDefault the limit is hard-coded at if (Updates!.length > 10e5) {
Updates = [];
if (IS_DEV) throw new Error("Potential Infinite Loop Detected.");
throw new Error();
}the destructive part is your options: 1. import { batch } from 'solid-js';
const CHUNK = 500_000;
for (let i = 0; i < cells.length; i += CHUNK) {
batch(() => {
for (let j = i; j < Math.min(i + CHUNK, cells.length); j++) {
setCellValue(cells[j], newValue);
}
});
}2. coarser-grained reactivity via 3. i'd lean toward option 2 for a matrix app. 1.6M signals is a lot of reactive overhead even without the limit. |
Beta Was this translation helpful? Give feedback.
@userNotFoundByDefault the limit is hard-coded at
10e5(1,000,000) inpackages/solid/src/reactive/signal.tsline 1355, insidewriteSignal:the destructive part is
Updates = []-- it wipes all pending computations before throwing, so you can't even recover. there's no config to raise or disable it.your options:
1.
batch()in chunks to reset the counter between flushes. eachbatch()call starts with a freshUpdates = [](line 885 in signal.ts), so the count resets: