Backtestsvuerun-20261002-115633#7506
suspense.resolve() is called without a pending branch.
The merged fix was judged better than our patch.
In this judgment, Patch B = our agent, Patch A = the merged fix.
The warning fires because the parent Suspense gets resolved while its own pending branch is still being patched. `patchSuspense` then calls `resolve()` again after the patch, when there is no pending branch left. Patch A wraps the same-root pending-branch patch with `suspense.deps++` / `suspense.deps--`. While the patch runs, nothing inside it can drop the boundary's deps to zero. That blocks every route to an early resolve: - a nested suspensible Suspense resolving synchronously; - the existing unmount path, where an unresolved async component removed from the pending branch decrements `parentSuspense.deps` and calls `resolve()` when it hits 0. The unmount path matches the issue's scenario. A router view is patched in place, and the pending async page is replaced because its setup navigated away. Removing that page drops the outer deps to 0 mid-patch, and the outer `patchSuspense` then calls `resolve()` a second time. A's guard covers this generically, and the parent resolves exactly once after the patch completes. Patch B targets only the nested-suspensible-Suspense path. It passes `sync=true` to every `resolve` call in `patchSuspense` and defers the parent's resolve to a guarded post-flush callback. This does fix the nested case, but it leaves the unmount-triggered mid-patch resolve untouched, so the direct router/async-page case can still warn. B also changes resolution timing more broadly. Any parent of a Suspense patched outside the parent's own patch now resolves in post-flush instead of immediately. That adds behavioural risk beyond the issue. Both patches add meaningful regression tests. A's second test also checks that a later sibling registering an async dep in the same patch is not skipped by a premature resolve. B's tests are thorough for the nested case, including the pending-branch-while-active-shown variants. Overall, A is minimal, targets the root cause in a way that covers more of the paths behind the reported warning, and carries less risk. B is broader in mechanism but narrower in what it actually fixes.
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
26m 17s
Wall-clock time in the container
Full test suite
No new failures
3,704 passed · 6 skipped · 3,710 total
Contamination audit
Clean
No sign the agent saw the real fix
Patch size
157vs 141 merged
Changed lines, ours vs merged
The issue
View on GitHubVue 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
packages/runtime-core/__tests__/components/Suspense.spec.tsindex 6b6373fab..46c7906b9 100644@@ -2879,6 +2879,130 @@ describe('Suspense', () => { expect(serializeInner(root)).toBe(`<div>B</div>`) }) + test('suspensible nested suspense resolving while parent is patched (parent in fallback)', async () => {+ const Async = defineAsyncComponent({+ render: () => h('div', 'async'),+ })+ const Sync = { render: () => h('div', 'sync') }+ const view = shallowRef<any>(Async)+ const onResolve = vi.fn()+ const root = nodeOps.createElement('div')+ const App = {+ setup() {+ return () =>+ h(+ Suspense,+ { onResolve },+ {+ default: () =>+ h('div', [+ h(+ Suspense,+ { suspensible: true },+ {+ default: () => h(view.value),+ fallback: () => h('span', 'inner fallback'),+ },+ ),+ ]),+ fallback: () => h('span', 'outer fallback'),+ },+ )+ },+ }++ render(h(App), root)+ expect(serializeInner(root)).toBe('<span>outer fallback</span>')++ // switch the inner branch to a sync one before the async one resolves.+ // the inner suspense resolves while the outer suspense is being patched.+ view.value = Sync+ await nextTick()+ expect(serializeInner(root)).toBe('<div><div>sync</div></div>')+ expect(onResolve).toHaveBeenCalledTimes(1)++ await Promise.all(deps)+ await nextTick()+ expect(serializeInner(root)).toBe('<div><div>sync</div></div>')+ expect(onResolve).toHaveBeenCalledTimes(1)+ })++ async function testNestedResolveInPendingBranch(viaProps: boolean) {+ const Async = defineAsyncComponent({+ render: () => h('div', 'async'),+ })+ const Sync = { render: () => h('div', 'sync') }+ const Home = { render: () => h('div', 'home') }+ const inner = shallowRef<any>(Async)+ const label = ref('before')+ // the inner suspense is followed by a sibling that is patched after the+ // inner suspense resolves. the update re-renders either the page itself or+ // (via props) the component rendering the outer suspense.+ const Page = {+ props: ['inner', 'label'],+ render: (ctx: any) =>+ h(Fragment, null, [+ h(+ Suspense,+ { suspensible: true },+ {+ default: () => h(viaProps ? ctx.inner : inner.value),+ fallback: () => h('span', 'inner fallback'),+ },+ ),+ h('p', viaProps ? ctx.label : label.value),+ ]),+ }+ const page = shallowRef<any>(Home)+ const root = nodeOps.createElement('div')+ const App = {+ setup() {+ return () =>+ h(Suspense, null, {+ default: () =>+ h(+ page.value,+ viaProps && page.value === Page+ ? { inner: inner.value, label: label.value }+ : null,+ ),+ fallback: () => h('span', 'outer fallback'),+ })+ },+ }++ render(h(App), root)+ expect(serializeInner(root)).toBe('<div>home</div>')++ // navigate to a page with an async dep: outer suspense becomes pending+ // while still showing the previous page+ page.value = Page+ await nextTick()+ expect(serializeInner(root)).toBe('<div>home</div>')++ // update the pending page before its async dep resolves+ inner.value = Sync+ label.value = 'after'+ await nextTick()+ expect(serializeInner(root)).toBe('<div>sync</div><p>after</p>')++ await Promise.all(deps)+ await nextTick()+ expect(serializeInner(root)).toBe('<div>sync</div><p>after</p>')++ page.value = Home+ await nextTick()+ expect(serializeInner(root)).toBe('<div>home</div>')+ }++ test('suspensible nested suspense resolving while parent is patched (pending branch, page update)', async () => {+ await testNestedResolveInPendingBranch(false)+ })++ test('suspensible nested suspense resolving while parent is patched (pending branch, parent update)', async () => {+ await testNestedResolveInPendingBranch(true)+ })+ describe('warnings', () => { // base function to check if a combination of slots warns or not function baseCheckWarn(packages/runtime-core/src/components/Suspense.tsindex 8a186fff2..d79c9d64e 100644@@ -259,7 +259,7 @@ function patchSuspense( optimized, ) if (suspense.deps <= 0) {- suspense.resolve()+ suspense.resolve(false, true) } else if (isInFallback) { // It's possible that the app is in hydrating state when patching the // suspense instance. If someone updates the dependency during component@@ -322,7 +322,7 @@ function patchSuspense( optimized, ) if (suspense.deps <= 0) {- suspense.resolve()+ suspense.resolve(false, true) } else if (!suspense.isFallbackMountPending) { // while the fallback mount is deferred to the leaving branch's // afterLeave, activeBranch is still the leaving content — see above@@ -353,7 +353,7 @@ function patchSuspense( optimized, ) // force resolve- suspense.resolve(true)+ suspense.resolve(true, true) } else { // switched to a 3rd branch patch(@@ -368,7 +368,7 @@ function patchSuspense( optimized, ) if (suspense.deps <= 0) {- suspense.resolve()+ suspense.resolve(false, true) } } }@@ -411,7 +411,7 @@ function patchSuspense( ) if (suspense.deps <= 0) { // incoming branch has no async deps, resolve now.- suspense.resolve()+ suspense.resolve(false, true) } else { const { timeout, pendingId } = suspense if (timeout > 0) {@@ -648,8 +648,27 @@ function createSuspenseBoundary( parentSuspenseId === parentSuspense.pendingId ) { parentSuspense.deps--- if (parentSuspense.deps === 0 && !sync) {- parentSuspense.resolve()+ if (parentSuspense.deps === 0) {+ if (sync) {+ // resolved synchronously during a mount or patch, which may be+ // part of patching the parent's pending branch. resolving the+ // parent now would move a partially patched branch, and the+ // parent may resolve itself once its own patch is done - so+ // only resolve it after the current flush if still needed.+ const pendingId = parentSuspense.pendingId+ queuePostFlushCb(() => {+ if (+ parentSuspense.pendingBranch &&+ !parentSuspense.isUnmounted &&+ parentSuspense.pendingId === pendingId &&+ parentSuspense.deps === 0+ ) {+ parentSuspense.resolve()+ }+ })+ } else {+ parentSuspense.resolve()+ } } } }
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) {