From aeed79c7e58e7711a9c5370faed82d49159f69fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9ry=20Debongnie?= Date: Mon, 2 Dec 2024 16:51:14 +0100 Subject: [PATCH] [REL] v2.5.2 # v2.5.2 - [FIX] runtime: make error recovery more robust --- docs/owl.js | 24 ++++++++++++++++++++---- package-lock.json | 2 +- package.json | 2 +- src/version.ts | 2 +- 4 files changed, 23 insertions(+), 7 deletions(-) diff --git a/docs/owl.js b/docs/owl.js index 3bcffa1ba..f6bbc7ec7 100644 --- a/docs/owl.js +++ b/docs/owl.js @@ -1625,6 +1625,13 @@ function makeRootFiber(node) { fibersInError.delete(current); fibersInError.delete(root); current.appliedToDom = false; + if (current instanceof RootFiber) { + // it is possible that this fiber is a fiber that crashed while being + // mounted, so the mounted list is possibly corrupted. We restore it to + // its normal initial state (which is empty list or a list with a mount + // fiber. + current.mounted = current instanceof MountFiber ? [current] : []; + } } return current; } @@ -1741,6 +1748,7 @@ class RootFiber extends Fiber { const node = this.node; this.locked = true; let current = undefined; + let mountedFibers = this.mounted; try { // Step 1: calling all willPatch lifecycle hooks for (current of this.willPatch) { @@ -1760,7 +1768,6 @@ class RootFiber extends Fiber { node._patch(); this.locked = false; // Step 4: calling all mounted lifecycle hooks - let mountedFibers = this.mounted; while ((current = mountedFibers.pop())) { current = current; if (current.appliedToDom) { @@ -1781,6 +1788,15 @@ class RootFiber extends Fiber { } } catch (e) { + // if mountedFibers is not empty, this means that a crash occured while + // calling the mounted hooks of some component. So, there may still be + // some component that have been mounted, but for which the mounted hooks + // have not been called. Here, we remove the willUnmount hooks for these + // specific component to prevent a worse situation (willUnmount being + // called even though mounted has not been called) + for (let fiber of mountedFibers) { + fiber.node.willUnmount = []; + } this.locked = false; node.app.handleError({ fiber: current || this, error: e }); } @@ -5604,7 +5620,7 @@ function compile(template, options = { } // do not modify manually. This file is generated by the release script. -const version = "2.5.1"; +const version = "2.5.2"; // ----------------------------------------------------------------------------- // Scheduler @@ -6082,6 +6098,6 @@ TemplateSet.prototype._compileTemplate = function _compileTemplate(name, templat export { App, Component, EventBus, OwlError, __info__, batched, blockDom, loadFile, markRaw, markup, mount, onError, onMounted, onPatched, onRendered, onWillDestroy, onWillPatch, onWillRender, onWillStart, onWillUnmount, onWillUpdateProps, reactive, status, toRaw, useChildSubEnv, useComponent, useEffect, useEnv, useExternalListener, useRef, useState, useSubEnv, validate, validateType, whenReady, xml }; -__info__.date = '2024-11-26T08:42:41.633Z'; -__info__.hash = '7fc552e'; +__info__.date = '2024-12-02T15:51:07.157Z'; +__info__.hash = '1c5b6f2'; __info__.url = 'https://github.com/odoo/owl'; diff --git a/package-lock.json b/package-lock.json index c1c1f39be..f6042c2d8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@odoo/owl", - "version": "2.5.1", + "version": "2.5.2", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index a6c32bd86..1924b9d44 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@odoo/owl", - "version": "2.5.1", + "version": "2.5.2", "description": "Odoo Web Library (OWL)", "main": "dist/owl.cjs.js", "module": "dist/owl.es.js", diff --git a/src/version.ts b/src/version.ts index b0d5b981e..8541a1232 100644 --- a/src/version.ts +++ b/src/version.ts @@ -1,2 +1,2 @@ // do not modify manually. This file is generated by the release script. -export const version = "2.5.1"; +export const version = "2.5.2";