Skip to content

Commit 9967645

Browse files
committedJan 11, 2023
fix: always update last HMR ms on a module
1 parent 7e38890 commit 9967645

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed
 

‎packages/vitest/src/node/core.ts

+8-3
Original file line numberDiff line numberDiff line change
@@ -403,9 +403,6 @@ export class Vitest {
403403

404404
private _rerunTimer: any
405405
private async scheduleRerun(triggerId: string) {
406-
const mod = this.server.moduleGraph.getModuleById(triggerId)
407-
if (mod)
408-
mod.lastHMRTimestamp = Date.now()
409406
const currentCount = this.restartsCount
410407
clearTimeout(this._rerunTimer)
411408
await this.runningPromise
@@ -447,8 +444,15 @@ export class Vitest {
447444

448445
private unregisterWatcher = noop
449446
private registerWatcher() {
447+
const updateLastChanged = (id: string) => {
448+
const mod = this.server.moduleGraph.getModuleById(id)
449+
if (mod)
450+
mod.lastHMRTimestamp = Date.now()
451+
}
452+
450453
const onChange = (id: string) => {
451454
id = slash(id)
455+
updateLastChanged(id)
452456
const needsRerun = this.handleFileChanged(id)
453457
if (needsRerun)
454458
this.scheduleRerun(id)
@@ -467,6 +471,7 @@ export class Vitest {
467471
}
468472
const onAdd = async (id: string) => {
469473
id = slash(id)
474+
updateLastChanged(id)
470475
if (await this.isTargetFile(id)) {
471476
this.changedTests.add(id)
472477
await this.cache.stats.updateStats(id)

0 commit comments

Comments
 (0)
Please sign in to comment.