Backtestsvuerun-20261005-124535#7506

Issue #7506 Merged fix PR #15411 Run 5 Oct 2026 · run-20261005-124535 vuejs/core

suspense.resolve() is called without a pending branch.

Better

Our patch was judged better than the merged fix.

In this judgment, Patch A = our agent, Patch B = the merged fix.

Both patches fix the same root cause. A nested suspensible Suspense can resolve synchronously while its parent's pending branch is still being patched in patchSuspense's same-type path. When that happens, it decrements the parent's deps to 0 and resolves the parent mid-patch. patchSuspense then calls suspense.resolve() a second time on a boundary that no longer has a pending branch, which triggers the reported warning. Both patches defer the parent's resolution until the patch finishes, so the post-patch `deps <= 0` check performs the single resolve. Patch A adds an explicit isPatchingPendingBranch flag that suppresses the nested-propagation resolve. Patch B temporarily bumps deps to hold the boundary pending. Both work, both leave a sibling registered later in the same patch counted before the final check, and neither handles an exception mid-patch (A's flag or B's extra dep would leak), so correctness is roughly equal. B is slightly more general, since it blocks any deps-reaching-zero path during the patch, but no other synchronous path exists in practice. A's flag follows the existing isFallbackMountPending convention and states its intent more explicitly than B's piggybacking on the dep counter, which other code also reads. On tests, A reproduces the issue's actual scenario: a page component whose async setup navigates to another page, both during setup and after an await. It covers single-root and multi-root layouts and asserts onResolve fires once, the final DOM, and mount order. B's tests are valid but more synthetic: they toggle routes on a never-resolving child, and one targets a sibling-dep edge case rather than the reported navigate-during-setup flow. Given equivalent correctness, A's more faithful and thorough regression coverage of the reported scenario and its clearer, convention-consistent mechanism give it the edge.

The judge saw only the two patches, labelled A and B in random order, with issue links and version numbers removed. The reasoning above is shown verbatim.

Solve

24m 25s

Wall-clock time in the container

Full test suite

No new failures

3,705 passed · 6 skipped · 3,711 total

Contamination audit

Clean

No sign the agent saw the real fix

Patch size

94vs 141 merged

Changed lines, ours vs merged

Vue version

3.2.45

Link to minimal reproduction

https://codesandbox.io/s/vue-router-playground-forked-w9164p?file=/src/pages/Page2.vue

Steps to reproduce

Create an application with vue and vue-router and the suspense component.

When creating a page, during the setup function navigate to another page (in my case this is how I handle an error) than this error is triggered.

What is expected?

Just no error message from vue / Suspense.

What is actually happening?

I get the following error message:

`
suspense.resolve() is called without a pending branch.
`

Nevertheless I can keep on using the application without any problems. I just want to get rid of the error message.

System Info

_No response_

Any additional comments?

_No response_

The two patches

Our patch+93 −1
packages/runtime-core/__tests__/components/Suspense.spec.tsindex 6b6373fab..f64c9df4d 100644@@ -1267,6 +1267,87 @@ describe('Suspense', () => {     expect(serializeInner(root)).toBe(`<div>innerB2</div>`)   }) +  // a nested suspensible Suspense that resolves while its parent's pending+  // branch is being patched resolves the parent; the parent must not be+  // resolved a second time afterwards+  describe('nested suspensible resolving parent during patch', () => {+    for (const navigate of ['during setup', 'after await'] as const) {+      for (const multiRoot of [false, true]) {+        const name = `navigate ${navigate}${multiRoot ? ' (multi-root)' : ''}`+        test(name, async () => {+          const calls: string[] = []+          const page = shallowRef<any>(null)++          const PageB = {+            setup() {+              onMounted(() => calls.push('page b mounted'))+              return () => h('div', 'page b')+            },+          }+          const PageA = {+            async setup() {+              // e.g. redirecting to another page on error+              if (navigate === 'during setup') page.value = PageB+              await new Promise(r => setTimeout(r))+              if (navigate === 'after await') page.value = PageB+              return () => h('div', 'page a')+            },+          }+          page.value = PageA++          const Layout = {+            props: ['page'],+            setup(props: any) {+              onMounted(() => calls.push('layout mounted'))+              return () => {+                const inner = h(+                  Suspense,+                  { suspensible: true },+                  {+                    default: () => h(props.page),+                    fallback: () => h('div', 'inner fallback'),+                  },+                )+                // the outer boundary must not be resolved (moved) before the+                // nodes after the inner boundary are patched+                return multiRoot ? [inner, h('div', 'footer')] : inner+              }+            },+          }++          const onResolve = vi.fn()+          const Comp = {+            setup() {+              return () =>+                h(+                  Suspense,+                  { onResolve },+                  {+                    default: () => h(Layout, { page: page.value }),+                    fallback: () => h('div', 'outer fallback'),+                  },+                )+            },+          }++          const root = nodeOps.createElement('div')+          render(h(Comp), root)+          expect(serializeInner(root)).toBe(`<div>outer fallback</div>`)++          await new Promise(r => setTimeout(r, 10))+          await nextTick()+          expect(serializeInner(root)).toBe(+            multiRoot+              ? `<div>page b</div><div>footer</div>`+              : `<div>page b</div>`,+          )+          expect(onResolve).toHaveBeenCalledTimes(1)+          expect(calls).toEqual([`layout mounted`, `page b mounted`])+        })+      }+    }+  })+   test('branch switch to 3rd branch before resolve', async () => {     const calls: string[] = [] packages/runtime-core/src/components/Suspense.tsindex 8a186fff2..fed5445d7 100644@@ -246,6 +246,10 @@ function patchSuspense(     suspense.pendingBranch = newBranch     if (isSameVNodeType(pendingBranch, newBranch)) {       // same root type but content may have changed.+      // a nested suspensible boundary that resolves during this patch must not+      // resolve this boundary while its pending branch is only partially+      // patched; it is resolved below once the patch is complete.+      suspense.isPatchingPendingBranch = true       patch(         pendingBranch,         newBranch,@@ -258,6 +262,7 @@ function patchSuspense(         slotScopeIds,         optimized,       )+      suspense.isPatchingPendingBranch = false       if (suspense.deps <= 0) {         suspense.resolve()       } else if (isInFallback) {@@ -437,6 +442,7 @@ export interface SuspenseBoundary {   hiddenContainer: RendererElement   activeBranch: VNode | null   isFallbackMountPending: boolean+  isPatchingPendingBranch: boolean   pendingBranch: VNode | null   deps: number   pendingId: number@@ -523,6 +529,7 @@ function createSuspenseBoundary(     timeout: typeof timeout === 'number' ? timeout : -1,     activeBranch: null,     isFallbackMountPending: false,+    isPatchingPendingBranch: false,     pendingBranch: null,     isInFallback: !isHydrating,     isHydrating,@@ -648,7 +655,11 @@ function createSuspenseBoundary(           parentSuspenseId === parentSuspense.pendingId         ) {           parentSuspense.deps---          if (parentSuspense.deps === 0 && !sync) {+          if (+            parentSuspense.deps === 0 &&+            !sync &&+            !parentSuspense.isPatchingPendingBranch+          ) {             parentSuspense.resolve()           }         } 
Merged fix · PR #15411+141 −0
packages/runtime-core/__tests__/components/Suspense.spec.tsindex 6b6373fab..68d71ebd1 100644@@ -2004,6 +2004,143 @@ describe('Suspense', () => {     ])   }) +  // toggling a nested suspensible suspense to sync content resolves the+  // parent boundary synchronously while it is still being patched; the+  // fallback fall-through must then be skipped or it patches the unmounted+  // fallback and corrupts activeBranch+  test('nested suspensible suspense toggled to sync content while parent is in fallback', async () => {+    const route = ref('a')+    const label = ref('first')++    const AsyncChild = {+      async setup() {+        await new Promise(() => {}) // never resolves+        return () => h('div', 'async child')+      },+    }+    const PageA = {+      setup: () => () => h('div', [h('span', 'page a'), h(AsyncChild)]),+    }+    const PageB = {+      setup: () => () => h('div', `page b ${label.value}`),+    }++    const Comp = {+      setup() {+        return () =>+          h(Suspense, null, {+            default: h('div', { 'data-label': label.value }, [+              h(+                Suspense,+                { suspensible: true },+                {+                  default:+                    route.value === 'a'+                      ? h(PageA, { key: 'a' })+                      : h(PageB, { key: 'b' }),+                },+              ),+            ]),+            fallback: h('div', 'fallback'),+          })+      },+    }++    const root = nodeOps.createElement('div')+    render(h(Comp), root)+    expect(serializeInner(root)).toBe(`<div>fallback</div>`)++    // the nested suspense resolves synchronously, propagates, and resolves+    // the outer boundary mid-patch+    route.value = 'b'+    await nextTick()+    expect(serializeInner(root)).toBe(+      `<div data-label="first"><div>page b first</div></div>`,+    )++    // a follow-up update must still reach the DOM+    label.value = 'second'+    await nextTick()+    expect(serializeInner(root)).toBe(+      `<div data-label="second"><div>page b second</div></div>`,+    )+  })++  // a nested suspensible suspense resolving synchronously inside the parent's+  // same-root patch must not resolve the parent before later siblings in the+  // same patch have registered their async deps+  test('nested suspensible suspense resolving the parent mid-patch while a later sibling registers an async dep', async () => {+    const route = ref('a')+    const show = ref(false)+    let releaseSibling: () => void+    const siblingGate = new Promise<void>(r => (releaseSibling = r))++    const NeverChild = {+      async setup() {+        await new Promise(() => {}) // never resolves+        return () => h('div', 'never')+      },+    }+    const Sibling = {+      async setup() {+        await siblingGate+        return () => h('div', 'sibling')+      },+    }+    const PageA = {+      setup: () => () => h('div', [h('span', 'page a'), h(NeverChild)]),+    }+    const PageB = {+      setup: () => () => h('div', 'page b'),+    }++    const onResolve = vi.fn()+    const Comp = {+      setup() {+        return () =>+          h(+            Suspense,+            { onResolve },+            {+              default: h('div', [+                h(+                  Suspense,+                  { suspensible: true },+                  {+                    default:+                      route.value === 'a'+                        ? h(PageA, { key: 'a' })+                        : h(PageB, { key: 'b' }),+                  },+                ),+                show.value ? h(Sibling) : null,+              ]),+              fallback: h('div', 'fallback'),+            },+          )+      },+    }++    const root = nodeOps.createElement('div')+    render(h(Comp), root)+    expect(serializeInner(root)).toBe(`<div>fallback</div>`)++    // the nested suspense resolves synchronously and releases the parent's+    // last dep, but the sibling mounted right after it is still pending+    route.value = 'b'+    show.value = true+    await nextTick()+    expect(serializeInner(root)).toBe(`<div>fallback</div>`)+    expect(onResolve).not.toHaveBeenCalled()++    releaseSibling!()+    await new Promise(r => setTimeout(r))+    expect(serializeInner(root)).toBe(+      `<div><div>page b</div><div>sibling</div></div>`,+    )+    expect(onResolve).toHaveBeenCalledTimes(1)+  })+   // #6416   test('KeepAlive with Suspense', async () => {     const Async = defineAsyncComponent({packages/runtime-core/src/components/Suspense.tsindex 8a186fff2..ba61c6340 100644@@ -246,6 +246,9 @@ function patchSuspense(     suspense.pendingBranch = newBranch     if (isSameVNodeType(pendingBranch, newBranch)) {       // same root type but content may have changed.+      // hold the boundary pending across the patch: a nested branch that+      // resolves in here must not resolve it before later siblings register.+      suspense.deps++       patch(         pendingBranch,         newBranch,@@ -258,6 +261,7 @@ function patchSuspense(         slotScopeIds,         optimized,       )+      suspense.deps--       if (suspense.deps <= 0) {         suspense.resolve()       } else if (isInFallback) {