Skip to content

[IMP] owl: declare signal and static props in the schema - #2032

Open
seb-odoo wants to merge 5 commits into
odoo:masterfrom
seb-odoo:master-signal-props--seb
Open

seb-odoo wants to merge 5 commits into
odoo:masterfrom
seb-odoo:master-signal-props--seb

Conversation

@seb-odoo

@seb-odoo seb-odoo commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

Before this commit, a signal prop cannot be declared in the schema: useProps() wraps a t.signal key like any other, so the child reads a signal of a signal, and declaring one takes useProps.static(name, type), one call per prop, outside the schema. The schema also has no way to say that a component only reads the signal it receives, or that it writes on it, so handing a read-only value to a component that writes is only caught when the write crashes.

.signal= has its own limit: the expression is evaluated during the parent's render, so every change of what it reads re-renders the parent just to refresh the wrapper. The suffix adapts a plain value to a signal prop, it does not save a render.

These commits give the schema keys their own behavior and move the evaluation into the child:

  • A t.signal(...) key is read once and exposed as is, read-only unless the prop is declared settable.
  • A plain value on such a key is promoted through a signal owned by the child, so a child can declare t.signal without touching any caller.
  • .static() brands any type, like .optional(), for a prop read once.
  • A .signal= expression is compiled into an arrow evaluated inside the cached computed, so the parent's render never subscribes to what the expression reads and a change updates the child alone.

Read-only itself becomes the absence of set: a computed declared without a set option no longer carries one that throws.

The first commit is a fix of owl on its own, also opened alone as owl#2066: two .signal= sites rendered by the same component, one of them in a t-call sub-template or in a slot, no longer share one value.

Note that this PR relies on owl#2065, where an effect disposed while it runs no longer runs again: a .signal= expression evaluated in the child reaches this case, when an effect of the child triggers the parent's render that destroys the child.

Closes #1907
Closes #1909

@seb-odoo

seb-odoo commented Sep 9, 2026

Copy link
Copy Markdown
Contributor Author

Hello @ged-odoo here is a tentative PR to fix what we believe are issues with the current props system.

I've adapted the current OWL branch into Odoo in these PR:

odoo/odoo#287375
https://github.com/odoo/enterprise/pull/130936

This includes all breaking changes to make the branch green (there are not many), and some adaptations in our code to highlight the new syntax.

@ged-odoo

ged-odoo commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

@seb-odoo thanks for this work. i am currently quite busy, but it looks interesting.

@ged-odoo

Copy link
Copy Markdown
Contributor

@seb-odoo

  • sorry, but there are now conflicts
  • question: you say "The problem is that a read-only reactive
    value cannot be told apart from a writable one". i wonder why that is a problem?

@seb-odoo

Copy link
Copy Markdown
Contributor Author

It's a problem if we want to do props validation, we need to be able to easily tell them apart without calling the method to see what it does.

I'll fix the conflicts.

@seb-odoo
seb-odoo force-pushed the master-signal-props--seb branch 2 times, most recently from ad65a58 to 4da7575 Compare September 22, 2026 13:31
@seb-odoo
seb-odoo force-pushed the master-signal-props--seb branch from 4da7575 to 3097885 Compare October 9, 2026 15:53
Comment on lines +214 to +216
// `fn` runs inside the cached computed, never here, so the parent's render
// does not subscribe to what the `.signal=` expression reads.
function toComputed(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[correctness, severity: 80%] .signal= throws once its parent t-if guard turns false.

A pending child render recomputes this computed before the parent re-renders, so this.state.record.n throws an unhandled TypeError once record is null.

Suggested resolution: keep evaluating the expression in the parent render, or make the deferred evaluation opt-in.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, fixed. I kept the evaluation in the child (that is the point of .signal=): when the expression throws while the parent or an ancestor has a render not applied yet, the computed keeps its last value, and runs the expression again once that render is patched. With no pending render, the error is thrown as before. It also covers a guard on an ancestor, not only on the direct parent.

Note that since alpha.50 the child's own render no longer showed the error, but an effect of the child reading the prop still did: the new tests read the prop in a useEffect.

Comment thread packages/owl-runtime/src/props.ts Outdated
function defineSignalProp(key: string, meta: SignalTypeMeta) {
const raw = resolveValue(node.props, key);
if (isReactiveValue(raw)) {
defineValueProp(key, meta.settable || !raw.set ? raw : computed(raw));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[correctness, severity: 60%] Read-only signal props miss signal.trigger updates.

computed(raw) compares with Object.is, so a triggered or equals: false signal that keeps the same object never re-renders the child.

Suggested change
defineValueProp(key, meta.settable || !raw.set ? raw : computed(raw));
defineValueProp(key, meta.settable || !raw.set ? raw : computed(raw, { equals: false }));

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, thanks.

Comment on lines +135 to +136
const promoted = signal(raw);
defineValueProp(key, computed(promoted));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[correctness, severity: 40%] An omitted optional signal prop is never undefined.

undefined is promoted like a plain value, so this.props.x ?? fallback never falls back, unlike on a settable key.

Suggested resolution: expose undefined for an omitted key, as the settable branch does.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An omitted signal key is promoted like a plain undefined: the child can always call this.props.x(), with no ?., and writes this.props.x() ?? fallback. Exposing undefined would make each read of an optional key a crash waiting for the one parent that omits it (odoo has 13 such keys). Settable is different: the child writes in the parent's signal, so there is nothing to promote. I added a line in the doc to make it clear.

Comment thread packages/owl-runtime/src/props.ts Outdated
Comment on lines +132 to +133
} else if (meta.settable) {
defineValueProp(key, raw);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[correctness, severity: 20%] An omitted settable prop ignores a later signal.

This branch registers no guardStaticProp, so a signal passed on a later render is dropped without a dev error.

Suggested resolution: register guardStaticProp here as in the other branches.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done: an omitted settable key now raises the same dev error as the other signal keys when a signal comes later.

Comment on lines +388 to +389
// `this` is the component, stable across renders: never a capture
if (captureNonLocals && token.value !== "this") {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[performance, severity: 0%] Parenthesized arrow parameters become captures.

(x) => x.id registers x before it turns local, so .signal= also captures ctx['x'] and compares it on every render.

Suggested resolution: drop the parameters from captureIndexes when they turn local.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, (x) => leaves an extra ctx['x'] in the captures. It costs one === per render, on a value that is almost always undefined. A plain delete of the key is not enough: the next index is the size of the map, so with (x = a) => a later capture would reuse the index of a, and with f(x, (x) => x) the outer x would lose its slot. I'd rather keep it as is than move the index assignment after the scan for this.

@seb-odoo
seb-odoo force-pushed the master-signal-props--seb branch from b90d00f to c2981e8 Compare October 23, 2026 22:09

@seb-odoo seb-odoo left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some notes on the choices made in this PR, to answer the questions before they come.


Disclaimer: these notes are AI-assisted, I read each one before sending it. As usual, feel free to challenge any of them.

Comment on lines +214 to +216
// `fn` runs inside the cached computed, never here, so the parent's render
// does not subscribe to what the `.signal=` expression reads.
function toComputed(

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, fixed. I kept the evaluation in the child (that is the point of .signal=): when the expression throws while the parent or an ancestor has a render not applied yet, the computed keeps its last value, and runs the expression again once that render is patched. With no pending render, the error is thrown as before. It also covers a guard on an ancestor, not only on the direct parent.

Note that since alpha.50 the child's own render no longer showed the error, but an effect of the child reading the prop still did: the new tests read the prop in a useEffect.

Comment thread packages/owl-runtime/src/props.ts Outdated
function defineSignalProp(key: string, meta: SignalTypeMeta) {
const raw = resolveValue(node.props, key);
if (isReactiveValue(raw)) {
defineValueProp(key, meta.settable || !raw.set ? raw : computed(raw));

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, thanks.

Comment on lines +135 to +136
const promoted = signal(raw);
defineValueProp(key, computed(promoted));

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An omitted signal key is promoted like a plain undefined: the child can always call this.props.x(), with no ?., and writes this.props.x() ?? fallback. Exposing undefined would make each read of an optional key a crash waiting for the one parent that omits it (odoo has 13 such keys). Settable is different: the child writes in the parent's signal, so there is nothing to promote. I added a line in the doc to make it clear.

Comment thread packages/owl-runtime/src/props.ts Outdated
Comment on lines +132 to +133
} else if (meta.settable) {
defineValueProp(key, raw);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done: an omitted settable key now raises the same dev error as the other signal keys when a signal comes later.

Comment on lines +388 to +389
// `this` is the component, stable across renders: never a capture
if (captureNonLocals && token.value !== "this") {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, (x) => leaves an extra ctx['x'] in the captures. It costs one === per render, on a value that is almost always undefined. A plain delete of the key is not enough: the next index is the size of the map, so with (x = a) => a later capture would reuse the index of a, and with f(x, (x) => x) the outer x would lose its slot. I'd rather keep it as is than move the index assignment after the scan for this.

Comment on lines +1183 to +1186
`${propName}: toComputed(node, ${cacheKey}, (__caps) => ${compiledValue}, [${captures}])`
);
} else {
props.push(`${propName}: toComputed(node, ${cacheKey}, () => ${compiledValue})`);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Object literals break in .signal= expressions. cfg.signal="{ mode: this.state.mode }" now compiles to () => {mode:ctx['this'].state.mode}, whose braces are the arrow's body, not an object: mode: is a label, so the child reads undefined. With a second key, the template fails to compile with Unexpected token ':'. It worked before, when the object was an argument of toSignal.

Suggested change
`${propName}: toComputed(node, ${cacheKey}, (__caps) => ${compiledValue}, [${captures}])`
);
} else {
props.push(`${propName}: toComputed(node, ${cacheKey}, () => ${compiledValue})`);
`${propName}: toComputed(node, ${cacheKey}, (__caps) => (${compiledValue}), [${captures}])`
);
} else {
props.push(`${propName}: toComputed(node, ${cacheKey}, () => (${compiledValue}))`);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, done: the compiled expression is now wrapped in parentheses, in the [PERF] commit that introduced the arrow, with a test "an object literal reaches the child" in props.test.ts.

const propName = /^[a-z_]+$/i.test(name) ? name : `'${name}'`;
this.helpers.add("toSignal");
this.helpers.add("toComputed");
const cacheKey = this.generateSignalCacheKey();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two .signal= sites can share one computed. The cache key lacks the render key, so a t-call sub-template or slot content shows another site's value on the same node, or the last item when a slot is called per item. It predates the PR, but the doc now promises the key that identifies the child.

Prefixing it with key, as generateComponentKey does, should solve it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, generateSignalCacheKey now prefixes the key with key, like generateComponentKey. Two tests cover it, the t-call sub-template and the slot called per item. It predates the PR but the doc now promises a computed per call site, so I put it in the [FIX] commit of the review gaps as a fourth gap.

@seb-odoo
seb-odoo force-pushed the master-signal-props--seb branch from c2981e8 to 0f2491a Compare November 6, 2026 12:31
Comment on lines +388 to +389
// `this` is the component, stable across renders: never a capture
if (captureNonLocals && token.value !== "this") {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.signal= freezes this under t-call-context. There this is the context object, not the component, and Odoo's kanban and activity records rebuild it on each render. The computed is built once and gets every other free variable again as a capture, but not this, so it keeps reading the first context; evaluated in the render, as before, it followed. Below, Child keeps the first record's name after this.state.index changes, while the rest of sub shows the new one:

<!-- parent -->
<t t-call="sub" t-call-context="this.state.records[this.state.index]"/>
<!-- sub -->
<Child name.signal="this.name"/>
Suggested change
// `this` is the component, stable across renders: never a capture
if (captureNonLocals && token.value !== "this") {
if (captureNonLocals) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, done as suggested: this is now a capture like any other free variable, so under t-call-context the computed follows the new context. Folded into the [PERF] commit that introduced the captures, with a test "a t-call-context sub-template follows the new context" in props.test.ts. The doc line on captures now names this under t-call-context.

Comment thread packages/owl-core/src/types.ts Outdated

function reactiveValueType(): Type<ReactiveValue<any>>;
function reactiveValueType<T>(): Type<ReactiveValue<T>>;
function reactiveValueType<T>(type: T): Type<ReactiveValue<StripBrands<T>>>;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Signal key types ignore promotion. An omitted optional key reads ReactiveValue<T> | undefined, so this.props.value() fails to typecheck, and GetProps rejects the plain values that promotion accepts.

Maybe the reader view could type a read-only signal key ReactiveValue<T | undefined> when optional, and the parent view accept T too.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done as you proposed, in the [FIX] commit of the review gaps as a fifth gap. t.signal() without settable carries a phantom Promotable brand: the reader view types an optional read-only key ReactiveValue<T | undefined>, and the parent view accepts T | ReactiveValue<T>. The Props brand now stores the parent view, so PropsWithDefaults is gone. Settable keys keep their types: they are not promoted, so an omitted one is really undefined. The type checks are in tests/types_signal_props.ts.

@seb-odoo
seb-odoo force-pushed the master-signal-props--seb branch from 0f2491a to b213f82 Compare November 6, 2026 15:16
return last;
} catch (error) {
// a t-if guard of a render not applied yet may no longer hold
const unapplied = evaluated && findUnappliedRender(node);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A first read still throws when the guard turns false. An effect such as if (this.state.open) this.props.n() reads the prop for the first time if open turns true in the same batch as record = null, so there is no last to return and the TypeError escapes.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, done. The computed now keeps a weak ref to the root fiber of the render that created it: a first read that throws while a later render is pending returns undefined and runs again after that render (the child is gone by then). An error during the render that created the computed is still thrown, that one is a real error of the expression on the first render of the child, simply dropping the evaluated check would have hidden it. The ref is weak so the cache does not keep that fiber tree alive. Two tests in props.test.ts: "no error on a first read in a child effect once a t-if guard turns false" and "an error on the first render of the child is not hidden". Folded into the [FIX] commit as a sixth gap.

Comment thread packages/owl-core/src/types.ts Outdated
Comment on lines +685 to +689
type ReadonlySignalType<T> = {
optional(): Optional<ReactiveValue<T>> & Promotable<T>;
optional(value: () => ReactiveValue<T>): WithDefault<ReactiveValue<T>> & Promotable<T>;
} & Type<ReactiveValue<T>> &
Promotable<T>;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.static() drops the promotion from signal types. t.signal(t.number()).optional().static() reads as ReactiveValue<number> | undefined and rejects a plain number, which props still promote.

What about leaving .static() off signal types, since the doc says a signal prop does not need it?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done as you proposed. Read-only signal types (and their .optional() forms) have static typed never, so .static() on them does not typecheck. Settable signal types keep it: they are not promoted, so nothing is lost (and it was already ignored at runtime for any signal). Doc line updated to "A read-only signal prop does not take it", type checks in tests/types_signal_props.ts. Seventh gap of the [FIX] commit.

@seb-odoo
seb-odoo force-pushed the master-signal-props--seb branch from b213f82 to 9e4de4a Compare November 6, 2026 19:57
} catch (error) {
// a t-if guard of a render not applied yet may no longer hold
const unapplied = findUnappliedRender(node);
if (!unapplied || (!evaluated && unapplied.fiber!.root === createdIn?.deref())) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A first read still throws while the child loads. When Child waits in onWillStart, the parent's re-render reuses the pending root fiber, so the check takes it for the render that created the computed:

const state = proxy({ open: false, record: null }); // Parent is mounted with it

class Child extends Component {
  static template = xml`<span/>`;
  props = useProps({ n: t.signal(t.number()) });
  setup() {
    onWillStart(() => new Promise(() => {})); // a load still running at tick 2
    useEffect(() => {
      if (state.open) {
        this.props.n();
      }
    });
  }
}

class Parent extends Component {
  static template = xml`<div><t t-if="this.state.record"><Child n.signal="this.state.record.n"/></t></div>`;
  static components = { Child };
  state = state;
}
tick 1   state.record = { n: 1 }
         Parent renders: its root fiber F stays pending (Child waits in onWillStart)
           └─ creates Child; toComputed(): createdIn = F, evaluated = false

tick 2   state.open = true; state.record = null        (one batch)
         Child's effect: first read of props.n()
           └─ this.state.record.n → TypeError
              findUnappliedRender(Child) runs Parent's render now
                makeRootFiber(Parent): F is still pending → reused
              !evaluated && F === createdIn → rethrown
         → unhandled TypeError

Not sure about the fix: comparing node.fiber and its recycle count lets the first read through, but the effect of the cancelled child then runs again after the patch and throws.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, done. Your idea was the right one for the first part: the computed now keeps a weak ref to the owner's own fiber and its recycle count (renderState >> 1, the applied bit is left out because MountFiber.complete() sets it between prepare() and mount()), so the reused pending root fiber no longer passes for the render that created the computed.

The throw you hit after the patch is a bug of effect in owl-core, older than this PR: the parent's render runs synchronously inside the child effect (findUnappliedRenders updates the parent render computation), it cancels the child, so the child effect is disposed while it runs. The rest of the run subscribed the disposed effect again, and the cleanup it returned was never called. Now an effect disposed during its own run unsubscribes at the end of that run (in a finally, so also when it throws) and calls the cleanup a normal run returned. Test in owl-core effect.test.ts.

While on it, the same family of cases got fixed, each with a test in props.test.ts: a guard on a grandparent while the child loads (the walk now runs the notified renders of every ancestor top down, so the ancestor render cancels the pending fibers below), a guard above a Portal, also while the child inside it loads (the walk goes to the host of a sub-root through subRootHosts whatever its status, above() only links a mounted sub-root), and the check also keeps the root fiber of the topmost pending node at creation, so a newer render above hides the read while a real error under the renders already pending at creation (first render, prepare(), Suspense content) is still thrown. Your exact case is ".signal suffix: no error on a first read in a child effect while the child loads". Eighth gap of the [FIX] commit.

@seb-odoo
seb-odoo force-pushed the master-signal-props--seb branch from 9e4de4a to 1566b39 Compare November 9, 2026 12:01
this.triggerRerunOnPatch();
}

triggerRerunOnPatch() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A first mount never reruns a hidden .signal= error. mount() and MountFiber._mount() clear the fiber without triggerRerunOnPatch(), unlike _patch(), so the child keeps a stale value and the error only surfaces on the parent's next render:

const state = proxy({ x: 1, tick: 0 });

class Child extends Component {
  static template = xml`<span t-out="this.props.n()"/>`;
  props = useProps({ n: t.signal(t.number()) });
}

class Loader extends Component {
  static template = xml`<i/>`;
  setup() {
    onWillStart(() => load()); // still running at tick 2
  }
}

class Parent extends Component {
  static template = xml`<Child n.signal="this.read()"/><Loader/><t t-out="this.state.tick"/>`;
  static components = { Child, Loader };
  state = state;
  read() {
    return state.x === 2 ? state.missing.y : state.x; // a bug when x is 2
  }
}
tick 1   mount(Parent): its MountFiber stays pending while Loader loads
           └─ Child renders n() = 1
tick 2   state.x = 2
           └─ Child re-reads n(): read() throws while the mount is pending
              → keeps 1, registers its rerun on Parent
tick 3   load() resolves: MountFiber._mount() applies the mount, no rerun
         → Child shows 1 while read() throws
tick 4   state.tick = 1: Parent._patch() runs the rerun
         → TypeError from an unrelated change

Calling triggerRerunOnPatch() after the fiber is cleared in mount() and MountFiber._mount() should solve it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 77846c9: mount() and MountFiber._mount() now call triggerRerunOnPatch() after clearing the fiber, as you wrote.

Testing around it showed two more cases of the same kind, fixed in the same commit:

  • After a crash in onMounted or onPatched, handleError puts the fiber back on the node. This fiber is applied and in fibersInError, so hasUnappliedRender no longer counts it as a pending render and it does not hide the error. Skipping every applied fiber was not possible: a root between prepare() and mount() keeps the applied bit and is still pending.
  • A useImmediateEffect of the child reads the expression inside signal.trigger, so the rerun can throw there. Each trigger is now in a try/catch that gives the error to handleError on the owner, the node that holds the .signal= prop, not the node whose render ended. For that, rerunOnPatch became a Map of rerun to owner.

cancelFibers and the prepare-only complete() need nothing: a cancelled mounted node is rendered again by the new render, a new node is destroyed, and prepare keeps its fiber until _mount.

There are 7 tests in a new describe of tests/components/props.test.ts: root mount, component added under a mounted parent, Suspense commit, render cancelled by a new one, owner whose patched hook crashed, root between prepare() and mount() under a t-if guard, immediate effect giving the error to the owner.

@seb-odoo
seb-odoo force-pushed the master-signal-props--seb branch from 1566b39 to 77846c9 Compare November 11, 2026 19:54
return last;
}
});
cache.set(cacheKey, entry);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed list items stay alive in the cache. Entries are never dropped and their captures hold each t-foreach item, so a list keeps every record it ever showed for as long as it lives.

Could solve it by dropping the entries the owner's last render did not reach, when it is patched.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, done as suggested in 164768c: the entries the last render of the owner did not reach are dropped when that render is applied. This is done at the patch and also at the mount, otherwise the items rendered at mount and removed by the first patch stayed until a second patch. The cache moved to the node, next to rerunOnPatch: a helper of template_helpers.ts imported in component_node.ts makes an import cycle. Test "the computed of a removed t-foreach item is released" in props.test.ts.

node.fiber!.renderState >> 1 === createdAt &&
unapplied[unapplied.length - 1].fiber!.root === createdRoot?.deref())
) {
throw error;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expression errors now skip the owner's onError. When the child reads the prop only in useEffect, the error goes unhandled, and in useImmediateEffect the state write that triggered it throws.

Maybe this branch could hand the error to handleError({ node, error }), as the rerun does, and keep last.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, done as suggested in 164768c: with no render pending, the error goes to handleError({ node, error }) and the computed keeps last. This is the behaviour of before the PR: the owner's onError gets the error and the child keeps its value. The first read under the render that created the computed is still thrown, as that render handles the error. Two tests in props.test.ts, "an error read in useEffect / useImmediateEffect goes to the owner's onError".

@seb-odoo
seb-odoo force-pushed the master-signal-props--seb branch from 77846c9 to 164768c Compare November 16, 2026 11:56

@seb-odoo seb-odoo left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated again... I didn't imagine it would take so many rounds. Maybe we should look to improve the process.

return last;
}
});
cache.set(cacheKey, entry);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, done as suggested in 164768c: the entries the last render of the owner did not reach are dropped when that render is applied. This is done at the patch and also at the mount, otherwise the items rendered at mount and removed by the first patch stayed until a second patch. The cache moved to the node, next to rerunOnPatch: a helper of template_helpers.ts imported in component_node.ts makes an import cycle. Test "the computed of a removed t-foreach item is released" in props.test.ts.

node.fiber!.renderState >> 1 === createdAt &&
unapplied[unapplied.length - 1].fiber!.root === createdRoot?.deref())
) {
throw error;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, done as suggested in 164768c: with no render pending, the error goes to handleError({ node, error }) and the computed keeps last. This is the behaviour of before the PR: the owner's onError gets the error and the child keeps its value. The first read under the render that created the computed is still thrown, as that render handles the error. Two tests in props.test.ts, "an error read in useEffect / useImmediateEffect goes to the owner's onError".

this.triggerRerunOnPatch();
}

sweepComputedCache() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A handled hook crash empties this cache. After a handled crash in onMounted or onPatched, the nodes above it are patched again without rendering, so the sweep drops all their entries. Their children keep the old computed, which gets no new captures: a t-foreach item replaced under the same t-key stays stale.

<t t-foreach="this.state.records" t-as="record" t-key="record.id">
  <Child name.signal="record.name"/>
</t>
<!-- its onError hides a child whose onMounted throws -->
<Handler t-if="this.state.crash"/>
mount    Child shows "a"
tick 1   state.crash = true
         Crasher's onMounted throws, Handler's onError hides it and re-renders
           └─ Parent is patched again without rendering → its cache is emptied
tick 2   state.records = [{ id: 1, name: "b" }]       (a reload: same id, new object)
         Parent renders: no cache entry → a new computed, which Child never receives
           └─ Child keeps the old computed, still reading the old record
         → Child shows "a"

Keeping the reached keys on the fiber that rendered them, rather than on the node, should solve it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, done as suggested in 1353db9: reachedComputedKeys moved from the node to the fiber, and the sweep reads the keys of the fiber being applied. The patch after a handled crash applies the same fiber again, so the sweep finds the same keys and the entries stay. makeRootFiber clears the set when it reuses a pending fiber, as it does for childrenMap. Test "a patch after a handled onMounted error keeps the computeds" in props.test.ts, with your example.

// a t-if guard of a render not applied yet may no longer hold
const unapplied = findUnappliedRenders(node);
if (!unapplied.length) {
handleError({ node, error });

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

onError handlers now run tracked by this computed. What a handler reads becomes a dependency of the expression, so each later change of it runs the expression again and reports the same error.

// Parent, with <Child v.signal="this.read()"/>
read() {
  return state.x === 1 ? 1 : state.missing.y;
}
setup() {
  onError((e) => log(`${e.message} (${state.theme} theme)`));
}
tick 1   state.x = 2
         Child reads v(): read() throws, Parent has no pending render
           └─ handleError runs inside the computed: onError reads state.theme
         → logs "Cannot read properties of undefined (reading 'y') (light theme)"
tick 2   state.theme = "dark"
         the computed now depends on theme: Child reads v() again, read() throws
         → logs "Cannot read properties of undefined (reading 'y') (dark theme)"
tick 3   state.theme = "light"
         → logs "Cannot read properties of undefined (reading 'y') (light theme)"

Calling it inside untrack() should solve it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, done as suggested in 1353db9: untrack(() => handleError({ node, error })), so what an onError reads is no longer a dependency of the expression. Test "what the owner's onError reads does not run the expression again" in props.test.ts.

@seb-odoo
seb-odoo force-pushed the master-signal-props--seb branch from 164768c to 1353db9 Compare November 16, 2026 18:01
}
}
if (disposed && typeof result === "function") {
result();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This cleanup subscribes the disposed effect again. It runs while the effect is still tracked, so a write to what it reads reruns a destroyed child's effect, whose .signal= read then destroys the app:

const state = proxy({ open: false, record: null, theme: "light" }); // Parent is mounted with it

class Child extends Component {
  static template = xml`<span/>`;
  props = useProps({ n: t.signal(t.number()) });
  setup() {
    onWillStart(() => new Promise(() => {})); // a load still running at tick 2
    useEffect(() => {
      if (state.open) {
        this.props.n();
      }
      return () => state.theme; // any read in the cleanup
    });
  }
}

class Parent extends Component {
  static template = xml`<div><t t-if="this.state.record"><Child n.signal="this.state.record.n"/></t></div>`;
  static components = { Child };
  state = state;
}
tick 1   state.record = { n: 1 }
         Parent renders Child, which waits in onWillStart
tick 2   state.open = true; state.record = null        (one batch)
         Child's effect reads n(): the expression throws, Parent's render cancels Child
           └─ the effect is disposed during its run, then runs this cleanup tracked
              → the disposed effect now depends on state.theme
tick 3   state.theme = "dark"
         the disposed effect runs again: n() throws, with no render pending
           └─ handleError finds no onError → the app is destroyed
Suggested change
result();
setComputation(undefined);
result();
setComputation(computation);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, thanks! Done, with a test in owl-core.

@seb-odoo
seb-odoo force-pushed the master-signal-props--seb branch from 1353db9 to 20a1c32 Compare November 18, 2026 10:37
Comment thread packages/owl-core/src/effect.ts Outdated
}

function createEffect<T>(fn: () => T, immediate: boolean) {
let disposed = false;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review fixes are stacked in one [FIX] commit. So the [IMP] and [PERF] commits land in owl's history with known bugs, and this effect fix, for a bug older than the PR, hides among the props fixes.

Folding each fix into the commit it corrects, and giving this one its own [FIX] owl-core: commit, would keep every commit sound.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, but with two more moves. The .signal= cache key fix is also a bug of master (two sites in a t-call sub-template or in a slot shared one value), so it has its own [FIX] owl-compiler: commit too, the second one. And "check plain signal values in props only" is folded into "support signal and static prop keys", as it corrected it. The final code is the same as the head you approved.

Comment on lines +174 to +175
A settable prop exposes the original signal, and validation requires the
received value to have a `set` method (a read-only computed is rejected).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other docs still describe the old contract. The counter example of owl3_design.md calls set on a signal prop that is now read-only, so a click throws. computed_values.md still has set throw an OwlError, and types_validation.md lacks settable and .static() and calls the t.signal type inference-only, as this page does further down.

Adding { settable: true } to that example and updating those passages should do it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@seb-odoo
seb-odoo force-pushed the master-signal-props--seb branch from 20a1c32 to 86910a3 Compare November 18, 2026 17:35
@seb-odoo

Copy link
Copy Markdown
Contributor Author

Own PR for fix 1: #2065
2nd fix pr coming too.

@seb-odoo

seb-odoo commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor Author

2nd fix: #2066

seb-odoo added a commit to seb-odoo/owl that referenced this pull request Nov 19, 2026
Before this commit, an effect disposed while it runs is not stopped: a
later write runs the effect again, and the cleanup function of the run
is never called.

Steps to reproduce:
- With two signals, `open` (false) and `value`, create this effect:

    const dispose = effect(() => {
      if (!open()) {
        return;
      }
      dispose();
      value();
      return () => console.log("cleanup");
    });

- `open.set(true)`: "cleanup" is not logged, where the cleanup should be
  called at the end of the run.
- `value.set(1)`: the effect runs again, where a disposed effect should
  never run.

The effect also runs again when the run throws after the dispose.

In owl, the effect of a component (`useEffect`) is disposed when the
component is destroyed, so the same happens when what the effect
triggers destroys the component synchronously.

This happens because the dispose removes the sources of the effect at
the time of the call, while the run goes on: what the run reads after
the dispose subscribes the effect again, and the cleanup function that
the run returns is stored as the next cleanup, which nothing calls.

After this commit, an effect disposed while it runs unsubscribes again
at the end of that run, whether the run returns or throws, and calls
the cleanup function that the run returned. The cleanup is called out
of any computation: while the effect is still the current computation,
what the cleanup reads would subscribe the disposed effect again.

Before this commit, a cleanup function that disposes its own effect
also loops without end (stack overflow), on a dispose and on a re-run:
the cleanup is called before `effect.value` is cleared, so the dispose
inside the cleanup finds the same cleanup and calls it again. This loop
is older than the fix above, and is fixed here as it is the same code.
After this commit, `effect.value` is cleared before the cleanup is
called, so the cleanup runs once. On a re-run, the body of the effect
is not called after such a dispose.

Note that a child effect (created inside another effect) that disposes
its parent while the child runs still runs again: the parent's dispose
reaches the child without marking it disposed, as the disposed state
is not on the computation, where a parent could reach it.

Taken from odoo#2032
@seb-odoo
seb-odoo force-pushed the master-signal-props--seb branch from 86910a3 to 32d5fd3 Compare November 19, 2026 15:24
seb-odoo added a commit to seb-odoo/owl that referenced this pull request Nov 19, 2026
Before this commit, an effect disposed while it runs is not stopped: a
later write runs the effect again, and the cleanup function of the run
is never called.

Steps to reproduce:
- With two signals, `open` (false) and `value`, create this effect:

    const dispose = effect(() => {
      if (!open()) {
        return;
      }
      dispose();
      value();
      return () => console.log("cleanup");
    });

- `open.set(true)`: "cleanup" is not logged, where the cleanup should be
  called at the end of the run.
- `value.set(1)`: the effect runs again, where a disposed effect should
  never run.

The effect also runs again when the run throws after the dispose.

In owl, the effect of a component (`useEffect`) is disposed when the
component is destroyed, so the same happens when what the effect
triggers destroys the component synchronously.

This happens because the dispose removes the sources of the effect at
the time of the call, while the run goes on: what the run reads after
the dispose subscribes the effect again, and the cleanup function that
the run returns is stored as the next cleanup, which nothing calls.

After this commit, an effect disposed while it runs unsubscribes again
at the end of that run, whether the run returns or throws, and calls
the cleanup function that the run returned. The cleanup is called out
of any computation: while the effect is still the current computation,
what the cleanup reads would subscribe the disposed effect again.

Before this commit, a cleanup function that disposes its own effect
also loops without end (stack overflow), on a dispose and on a re-run:
the cleanup is called before `effect.value` is cleared, so the dispose
inside the cleanup finds the same cleanup and calls it again. This loop
is older than the fix above, and is fixed here as it is the same code.
After this commit, `effect.value` is cleared before the cleanup is
called, so the cleanup runs once. On a re-run, the body of the effect
is not called after such a dispose.

Before this commit, a child effect (created inside another effect)
that disposes its parent while the child runs is not stopped either.

Steps to reproduce:
- With the same two signals, create this effect:

    const disposeParent = effect(() => {
      effect(() => {
        if (!open()) {
          return;
        }
        disposeParent();
        value();
        return () => console.log("child cleanup");
      });
    });

- `open.set(true)`: "child cleanup" is not logged at the end of the
  run.
- `value.set(1)`: the disposed child runs again, and only then the
  cleanup of its previous run is called.

In owl, the same happens when what a nested effect triggers destroys
the component of the outer `useEffect`.

This happens because the parent's dispose reaches the child through
the recursive unsubscribe of the parent's children, which only removes
the sources of the child at the time of the call, as the dispose of an
effect does: what the run of the child reads afterwards subscribes it
again, and the cleanup function that the run returns is stored.

After this commit, the disposed state is a DISPOSED bit of the
computation flags. The dispose function sets it on the effect, and the
parent's dispose or re-run sets it on each child it unsubscribes, as a
re-run makes new children. The end of a run that is still in progress
reads that bit, so a child disposed by its parent during its run
unsubscribes again and calls its cleanup, as an effect that disposes
itself does.

Taken from odoo#2032
seb-odoo added a commit to seb-odoo/owl that referenced this pull request Nov 19, 2026
Before this commit, an effect disposed while it runs is not stopped: a
later write runs it again, and the cleanup function of the run is never
called. In owl, `useEffect` is disposed when its component is destroyed,
so this happens when what the effect triggers destroys the component.

Steps to reproduce:
- With two signals, `open` (false) and `value`, create this effect:

    const dispose = effect(() => {
      if (!open()) {
        return;
      }
      dispose();
      value();
      return () => console.log("cleanup");
    });

- `open.set(true)`: "cleanup" is not logged at the end of the run.
- `value.set(1)`: the disposed effect runs again.

The same happens when a child effect (created inside another effect)
disposes its parent while the child runs.

This happens because the dispose, of the effect or of its parent, only
removes the sources at the time of the call while the run goes on: what
the run reads afterwards subscribes the effect again, and the cleanup
that the run returns is stored, which nothing calls.

After this commit, a DISPOSED flag is set on the effect by its dispose,
and on each child by its parent's dispose or re-run. At the end of a
run, whether it returns or throws, a disposed effect unsubscribes again
and calls the cleanup that the run returned, out of any computation.

Also, a cleanup that disposes its own effect looped without end, as the
cleanup was called before `effect.value` was cleared. It is now cleared
first, so the cleanup runs once.

Taken from odoo#2032
ged-odoo pushed a commit that referenced this pull request Nov 20, 2026
Before this commit, an effect disposed while it runs is not stopped: a
later write runs it again, and the cleanup function of the run is never
called. In owl, `useEffect` is disposed when its component is destroyed,
so this happens when what the effect triggers destroys the component.

Steps to reproduce:
- With two signals, `open` (false) and `value`, create this effect:

    const dispose = effect(() => {
      if (!open()) {
        return;
      }
      dispose();
      value();
      return () => console.log("cleanup");
    });

- `open.set(true)`: "cleanup" is not logged at the end of the run.
- `value.set(1)`: the disposed effect runs again.

The same happens when a child effect (created inside another effect)
disposes its parent while the child runs.

This happens because the dispose, of the effect or of its parent, only
removes the sources at the time of the call while the run goes on: what
the run reads afterwards subscribes the effect again, and the cleanup
that the run returns is stored, which nothing calls.

After this commit, a DISPOSED flag is set on the effect by its dispose,
and on each child by its parent's dispose or re-run. At the end of a
run, whether it returns or throws, a disposed effect unsubscribes again
and calls the cleanup that the run returned, out of any computation.

Also, a cleanup that disposes its own effect looped without end, as the
cleanup was called before `effect.value` was cleared. It is now cleared
first, so the cleanup runs once.

Taken from #2032
Before this commit, two `.signal=` sites rendered by the same component
can show the same value, when one of them is in a `t-call` sub-template
or in a slot.

Steps to reproduce:
- Mount a component with the state `{ a: "A", b: "B" }` and the template
  `<div><Child v.signal="this.state.a"/><t t-call="sub"/></div>`, where
  the template `sub` is `<Child v.signal="this.state.b"/>`. The
  component shows B B, where A B is expected.
- Mount a `List` that calls its default slot once per item of
  `["x", "y", "z"]` (a `t-call-slot` in a `t-foreach`), with the slot
  `<Item v.signal="scope.item"/>`. The list shows z z z, where x y z is
  expected.

This happens because the signals of the `.signal=` sites are cached per
owner node, under the key `__sig_N` followed by the `t-foreach` keys of
the template, and the counter N restarts for each compiled template. A
`t-call` sub-template and a slot are compiled apart, but render on the
owner node. They pass their own render `key`, which the cache key
ignores, so both sites get the same entry.

After this commit, the cache key of a `.signal=` site starts with the
render `key`, as the key of a component does, so that each site has its
own entry.
Before this commit, a computed without a `set` option gets a `set`
method that always throws. The problem is that a read-only reactive
value cannot be told apart from a writable one: `set` is present on
both, and the only way to know is to call it and catch. Props
validation then has no way to reject a read-only value handed to a
component that writes on it.

This commit leaves `set` off a computed that has no `set` option, so
that read-only is checked by the absence of `set`. `ReactiveValue`
declares `set` optional, and `WritableReactiveValue` names the shape
with a guaranteed `set`, returned by `computed` when a `set` option
is given. `Portal` asks for a `ReactiveValue` target, as it only
reads it, and `ErrorBoundary` asserts `set` on its error prop, which
its default factory guarantees.
Before this commit, two prop contracts have no place in the schema. A
prop that the component reads only once must be declared with
`useProps.static(name, type)`, outside of `useProps()`. A component
that writes on a received signal cannot declare that it will, so
handing it a read-only value is only caught when the write crashes.

This commit adds `.static()` on every type and a `settable` option on
`types.signal()`. `.static()` is a brand like `.optional()` and
composes with it in any order; it is only meaningful on a prop, so
validation rejects it on a nested key. `settable` requires a `set`
method on the reactive value, and is checked wherever the signal type
sits in the schema. `isStaticType` and `getSignalType` let `useProps`
read the brands through the wrapper chain.
Before this commit, `useProps()` treats a `t.signal` key as any other
key: the received signal lands inside the per-key wrapper signal, so
the child reads a signal of a signal, and each parent render replaces
it. The alternative is `useProps.static(name, type)`, one call per
prop, outside the schema, assigned to a flat component field.

This commit gives the schema keys their own behavior:

- A `t.signal(...)` key is read once and exposed as is; the prop is
  static (dev throws when the parent passes another signal). The view
  is read-only: a writable signal is wrapped in a computed without
  `set`, unless the prop is declared `settable`, which exposes the
  original signal. That computed has `equals: false`, so that the view
  follows `signal.trigger` on a signal that keeps the same object. A
  settable key is guarded like the other signal keys: an omitted one
  that is given a signal on a later render throws in dev.
- A plain value on a signal key is promoted: it is served through a
  signal owned by the child, updated on parent renders, so a child
  can declare `t.signal` without touching any caller. Alternating
  between a plain value and a signal throws in dev.
- A `.static()` key is read once, assigned unwrapped and guarded in
  dev, like `useProps.static` does for one named prop.

Only `useProps` accepts a plain value on a signal key: it wraps its
read-only signal keys with `promotableType`, which checks a plain value
against the inner type. Anywhere else (`useConfig`, a key nested in
`t.object(...)`), `t.signal(...)` stays a check of a reactive value, as
nothing promotes a plain value there.

The types follow the promotion. `types.signal()` without `settable` is
branded `Promotable`: the reader view types an optional read-only key
`ReactiveValue<T | undefined>`, as props promote the key even when
omitted, and the parent view accepts `T | ReactiveValue<T>`. The
`Props` brand stores the parent view itself, so `PropsWithDefaults`
goes. A settable key keeps its types: props do not promote it, so an
omitted one is really undefined.

A read-only signal type has no `.static()` (typed `never`): a signal
prop is static by nature, and the `Static` wrapper would drop the
promotion brand. A settable signal type keeps `.static()`.

`ErrorBoundary` declares its error prop settable, as it writes on it.
The counter example of owl3_design.md does the same: it writes on its
prop, which would throw on click with a read-only view.

Closes odoo#1907
Before this commit, a `.signal=` expression is evaluated during the
parent's render: `toSignal` wraps the result in a cached signal, and
the parent's render subscribes to everything the expression reads.
Every change of the read value re-renders the parent just to refresh
the wrapper, so the suffix is an adapter for signal-based props, not
an optimization.

This commit compiles the expression into an arrow evaluated inside
the cached computed (`toComputed`): the parent's render never
subscribes to what the expression reads, and a change only
invalidates the computed, which updates the child alone.

Render-scope variables (a t-foreach item, a t-set value, `this` under
`t-call-context`) cannot be closed over, as the arrow of the first
render is the one kept: the compiler passes them as an array of
captures, compared shallowly on each parent render and read by the
computed through a signal, so a changed capture re-evaluates the
expression. `this` is the component, stable across renders, except
under `t-call-context`, where `this` is the context object, which the
caller may rebuild on each render: the compiler captures `this` like
any other free variable.

An expression reading only non-reactive state now evaluates once
instead of refreshing on unrelated parent renders: a constant stays
fine, a plain mutable field needs a signal or a proxy.

Evaluating in the child means that a reader of the child (an effect, a
computed) can run the expression before the render that removes the
child. With `<Child n.signal="state.record.n"/>` inside
`<t t-if="state.record">`, `state.record = null` makes an effect of
the child read `null.n` before the parent renders. Therefore, an
expression that throws is handled as follows, where the owner is the
component that renders the `.signal=` site:

- While the owner or an ancestor has a render not applied yet, the
  computed keeps its last value, `undefined` on a first read, and runs
  the expression again once that render is applied: the `t-if` guard
  may no longer hold, and that render then removes the child. The
  guard can be in an ancestor, or above a `Portal` or a `Suspense`,
  whose sub-root has no parent, so the lookup goes up through the host
  of a sub-root. The effect of the child can also run before a render
  already notified, so the lookup first runs these renders, top down:
  the render of an ancestor cancels the pending fibers below, as the
  fiber of a child still in `onWillStart`.
- The expression runs again at a first mount too, of a root, of a
  sub-root or of a component added by the patch of its parent, and not
  only at a patch. Otherwise the child would keep the last value while
  the expression throws, until the next render of the owner.
- A first read that throws is still thrown while the renders pending
  when the computed was created are the only ones: this is an error of
  the expression on the first render of the child, which that render
  handles.
- A fiber that `handleError` put back on its node, after a crash in an
  `onMounted` or `onPatched` hook that an `onError` handles, does not
  count as a pending render, as that fiber is already applied.
  Otherwise the expression would keep its last value, with no error,
  until the crashed component renders again.
- With no render pending, the error goes to the error handlers of the
  owner and the computed keeps its last value, as when the expression
  ran in the render of the owner. A throw out of a render only reaches
  the reader of the computed: from a `useEffect`, this is an unhandled
  rejection that the `onError` of the owner never gets.
- An error of the run after a render is applied goes to the error
  handlers of the owner as well. A child that reads the prop in a
  `useImmediateEffect` runs the expression inside the mount or the
  patch, which would take the error for a crash of their own: the
  `onMounted` hooks would not run and `mount()` would never resolve.

The computeds are cached on the node that renders the site, a slot
included. A render notes on its fiber the cache keys that it reaches,
and the other entries are dropped when that render is applied. An
entry holds its captures, so the entry of a removed `t-foreach` item
would keep the item alive for as long as the owner lives.

Note that the test of the removed `t-foreach` item uses `WeakRef` and
`gc()`, so the vitest config of owl-runtime passes `--expose-gc`.

Closes odoo#1909
@seb-odoo
seb-odoo force-pushed the master-signal-props--seb branch from 32d5fd3 to 1988e71 Compare November 20, 2026 13:25

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

optimize .signal= props passing types validation for ReactiveValue and read-only passing

3 participants