mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
[FIX] component: error_handling on current component
Have a Child Compnent which has one component that succeeds and another one that fails at its instanciation. The Child component handles the Errors by rendering itself. Before this commit, the error handling algorithm made impossible for the scheduler to finish. This was because the current fiber was still counted as ongoing, when it was actually completed. After this commit, this use case is handled correctly.
This commit is contained in:
committed by
Géry Debongnie
parent
e97335d7ab
commit
50c0e30936
@@ -140,7 +140,7 @@ export class ComponentNode<T extends typeof Component = any> implements VNode<Co
|
||||
if (fiber && !fiber.bdom && !fibersInError.has(fiber)) {
|
||||
return fiber.root.promise;
|
||||
}
|
||||
if (!this.bdom && !this.fiber) {
|
||||
if (!this.bdom && !fiber) {
|
||||
// should find a way to return the future mounting promise
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import type { Fiber } from "./fibers";
|
||||
export const fibersInError: WeakMap<Fiber, Error> = new WeakMap();
|
||||
export const nodeErrorHandlers: WeakMap<ComponentNode, ((error: Error) => void)[]> = new WeakMap();
|
||||
|
||||
function _handleError(node: ComponentNode | null, error: Error): boolean {
|
||||
function _handleError(node: ComponentNode | null, error: Error, isFirstRound = false): boolean {
|
||||
if (!node) {
|
||||
return false;
|
||||
}
|
||||
@@ -15,7 +15,7 @@ function _handleError(node: ComponentNode | null, error: Error): boolean {
|
||||
|
||||
const errorHandlers = nodeErrorHandlers.get(node);
|
||||
if (errorHandlers) {
|
||||
if (fiber && !fiber.children.length) {
|
||||
if (isFirstRound && fiber) {
|
||||
fiber.root.counter--;
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ export function handleError(node: ComponentNode, error: Error) {
|
||||
const fiber = node.fiber!;
|
||||
fibersInError.set(fiber.root, error);
|
||||
|
||||
if (!_handleError(node, error)) {
|
||||
if (!_handleError(node, error, true)) {
|
||||
try {
|
||||
node.app.destroy();
|
||||
} catch (e) {}
|
||||
|
||||
Reference in New Issue
Block a user