fix(ssr): prevent watch() from firing after async setup await#14547
fix(ssr): prevent watch() from firing after async setup await#14547edison1105 merged 2 commits intomainfrom
Conversation
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughUpdate preserves and restores SSR-specific setup state across async boundaries in withAsyncContext, exports the SSR setup state setter, and adds a test ensuring watchers registered after async restore are not run during SSR. Changes
Sequence Diagram(s)sequenceDiagram
participant ComponentSetup as "Component.setup()"
participant withAsync as "withAsyncContext"
participant SSRFlag as "isInSSRComponentSetup"
participant Watcher as "watch() / reactivity"
participant Renderer as "SSR renderer"
ComponentSetup->>withAsync: enter async block
withAsync->>SSRFlag: record & set false (disable SSR setup)
withAsync->>ComponentSetup: await async work
withAsync-->>ComponentSetup: restore() (re-apply instance & SSRFlag rgba(0,128,0,0.5))
ComponentSetup->>Watcher: register watcher (post-restore)
Renderer->>Watcher: evaluate during SSR (skipped because SSRFlag restored correctly)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Comment |
Size ReportBundles
Usages
|
@vue/compiler-core
@vue/compiler-dom
@vue/compiler-sfc
@vue/compiler-ssr
@vue/reactivity
@vue/runtime-core
@vue/runtime-dom
@vue/server-renderer
@vue/shared
vue
@vue/compat
commit: |
|
/ecosystem-ci run |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/server-renderer/__tests__/ssrWatch.spec.ts (1)
124-160: Add the rejected-await path too.This spec covers the resolved restore flow, but
packages/runtime-core/src/apiSetupHelpers.tsalso changed the rejection branch at Lines 543-549. A matching SSR test with a rejected awaitable insidetry/catchwould pin down the newrestore()behavior there as well.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/server-renderer/__tests__/ssrWatch.spec.ts` around lines 124 - 160, Add a parallel test that exercises the rejected-await path: inside the async setup of the App (the same structure using withAsyncContext -> [__temp, __restore] and calling __restore()), await a Promise that rejects inside a try/catch so the restoration branch that handles rejections in withAsyncContext/restore() is exercised; register the same before-await and after-await watchers around the await/restore sequence, mutate text.value, assert ctx.__watcherHandles remains undefined, assert HTML output and that neither beforeAwaitTriggered nor afterAwaitTriggered fire after nextTick, and ensure the test name reflects the "rejected" case to mirror the existing resolved test.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@packages/server-renderer/__tests__/ssrWatch.spec.ts`:
- Around line 124-160: Add a parallel test that exercises the rejected-await
path: inside the async setup of the App (the same structure using
withAsyncContext -> [__temp, __restore] and calling __restore()), await a
Promise that rejects inside a try/catch so the restoration branch that handles
rejections in withAsyncContext/restore() is exercised; register the same
before-await and after-await watchers around the await/restore sequence, mutate
text.value, assert ctx.__watcherHandles remains undefined, assert HTML output
and that neither beforeAwaitTriggered nor afterAwaitTriggered fire after
nextTick, and ensure the test name reflects the "rejected" case to mirror the
existing resolved test.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 6b0b23eb-309f-4e51-9d38-28212021541c
📒 Files selected for processing (3)
packages/runtime-core/src/apiSetupHelpers.tspackages/runtime-core/src/component.tspackages/server-renderer/__tests__/ssrWatch.spec.ts
|
📝 Ran ecosystem CI: Open
|
close #14546
Summary by CodeRabbit
Bug Fixes
Tests