Skip to content

Commit 748028e

Browse files
committed
refactor(reactivity): move warning for active effect restoration to endTracking function
1 parent c94d305 commit 748028e

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

packages/reactivity/src/effect.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -119,12 +119,6 @@ export class ReactiveEffect<T = any>
119119
try {
120120
return this.fn()
121121
} finally {
122-
if (__DEV__ && activeSub !== this) {
123-
warn(
124-
'Active effect was not restored correctly - ' +
125-
'this is likely a Vue internal bug.',
126-
)
127-
}
128122
endTracking(this, prevSub)
129123
const flags = this.flags
130124
if (

packages/reactivity/src/system.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import type { ComputedRefImpl as Computed } from './computed.js'
44
import type { ReactiveEffect as Effect } from './effect.js'
55
import type { EffectScope } from './effectScope.js'
6+
import { warn } from './warning.js'
67

78
export interface ReactiveNode {
89
deps?: Link
@@ -234,13 +235,20 @@ export function endTracking(
234235
sub: ReactiveNode,
235236
prevSub: ReactiveNode | undefined,
236237
): void {
238+
if (__DEV__ && activeSub !== sub) {
239+
warn(
240+
'Active effect was not restored correctly - ' +
241+
'this is likely a Vue internal bug.',
242+
)
243+
}
244+
activeSub = prevSub
245+
237246
const depsTail = sub.depsTail
238247
let toRemove = depsTail !== undefined ? depsTail.nextDep : sub.deps
239248
while (toRemove !== undefined) {
240249
toRemove = unlink(toRemove, sub)
241250
}
242251
sub.flags &= ~ReactiveFlags.RecursedCheck
243-
activeSub = prevSub
244252
}
245253

246254
export function flush(): void {

0 commit comments

Comments
 (0)