Skip to content

bug: v5 componentShouldUpdate returning false leaves the parent component waiting forever #7038

Done

Description

@henrijoss

Stencil Version

5.0.0-rc.9

Current Behavior

When a child component's componentShouldUpdate returns false, its parent never finishes the update it is in: componentDidRender and componentDidUpdate of the parent are not called. The parent then stays in "waiting for children", so every later update of the parent is deferred and never happens either.

In the reproduction, the parent passes a new object with the same content to the child on every render, and the child's componentShouldUpdate returns false for it. After the first click the parent renders once more (count 1) without its componentDidRender, and then stops updating: the count stays at 1.

Expected Behavior

The parent finishes its update whether or not a child skips its own: componentDidRender and componentDidUpdate run after every update, and the count goes up with every click.

This is what 4.45.1 does with the same two components: count 3, componentDidRender 4 times, componentDidUpdate 3 times.

System Info

      System: node 22.21.0
    Platform: darwin (27.0.0)
   CPU Model: Apple M2 Pro (12 cpus)
     Stencil: 5.0.0-rc.9 🏐
  TypeScript: 6.0.3
    Rolldown: 1.3.3
      Terser: 5.51.4

Browsers: Chromium and WebKit (Playwright 1.63)

Steps to Reproduce

  1. Clone https://github.com/henrijoss/stencil-v5-repros and run npm install
  2. npm start --workspace=should-update-parent and open http://localhost:3333
  3. Click the button three times

The log only shows parent componentDidRender (count: 0) from the first render, and the rendered count stays at 1.

Code Reproduction URL

https://github.com/henrijoss/stencil-v5-repros/tree/main/should-update-parent

Additional Information

Since the batched componentShouldUpdate (#6783), setValue() calls scheduleUpdate() first, and componentShouldUpdate is only called later in dispatchHooks(). By then scheduleUpdate() has run attachToAncestor(), which pushed a promise into the parent's s-p. When componentShouldUpdate returns false, dispatchHooks() returns without resolving it (packages/core/src/runtime/update-component.ts):

if (safeCall(instance, 'componentShouldUpdate', changes, elm) === false) {
  hostRef.$flags$ &= ~HOST_FLAGS.isQueuedForUpdate;
  return;
}

Stencil 4 called componentShouldUpdate in setValue() and didn't schedule an update when it returned false, so the parent was never made to wait.

Resolving the promise before the early return fixes the reproduction (count 3, 4 × componentDidRender, 3 × componentDidUpdate, as with 4.45.1). The catch in initializeComponent() does the same:

if (BUILD.asyncLoading && hostRef.$onRenderResolve$) {
  hostRef.$onRenderResolve$();
  hostRef.$onRenderResolve$ = undefined;
}

The code is the same in 5.0.0-rc.10; I only ran rc.9 (and first saw this with rc.1).

I found no existing issue for this.

Activity

  1. johnjenkins commented on Nov 25, 2026

    @johnjenkins
    Contributor

    TYSM for trying out v5. This was fixed in 5.0.0-rc.11 🥳

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions