Skip to content

--watch not running with last file content when file changes multiple times #48909

Closed
@GabbeV

Description

@GabbeV

Version

v20.5.0

Platform

No response

Subsystem

No response

What steps will reproduce the bug?

  1. create an empty file called watchthis.js
  2. create another file called runthis.js with the following content:
const { writeFileSync } = require("fs")

writeFileSync("./watchthis.js", "console.log('foo')")
setTimeout(() => {
	writeFileSync("./watchthis.js", "console.log('bar')")
}, 100)
  1. run node --watch ./watchthis.js in a terminal
  2. run node runthis.js in another terminal

How often does it reproduce? Is there a required condition?

Every time

What is the expected behavior? Why is that the expected behavior?

The last printed value in the first terminal should be "bar".

What do you see instead?

The last printed value is "foo".

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    watch-modeIssues and PRs related to watch mode

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions