Skip to content

Commit 36ee503

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

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
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: 7 additions & 0 deletions
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,6 +235,12 @@ 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+
}
237244
const depsTail = sub.depsTail
238245
let toRemove = depsTail !== undefined ? depsTail.nextDep : sub.deps
239246
while (toRemove !== undefined) {

0 commit comments

Comments
 (0)