[FIX] runtime: properly handle error caused in mounted hook

If a component onMounted hook causes an error, and an error handler
tries to reinitiate a new correct render, the fiber may be recycled. But
the scheduler removes it from its own set of tasks, so it will be
ignored.

We simply check for this condition before removing it from the tasks
set.
This commit is contained in:
Géry Debongnie
2024-11-22 10:44:45 +01:00
committed by aab-odoo
parent 26c7856d5d
commit 968e96ad08
3 changed files with 128 additions and 1 deletions
+8 -1
View File
@@ -93,7 +93,14 @@ export class Scheduler {
if (!hasError) {
fiber.complete();
}
this.tasks.delete(fiber);
// at this point, the fiber should have been applied to the DOM, so we can
// remove it from the task list. If it is not the case, it means that there
// was an error and an error handler triggered a new rendering that recycled
// the fiber, so in that case, we actually want to keep the fiber around,
// otherwise it will just be ignored.
if (fiber.appliedToDom) {
this.tasks.delete(fiber);
}
}
}
}