Skip to content

node --test --watch hangs on invalid import syntax #62021

@valler

Description

@valler

Version

25

Platform

Darwin

Subsystem

No response

What steps will reproduce the bug?

  1. The test file
// test.mjs
import
  1. Run
node --test --watch
  1. Any change
touch test.mjs

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

always

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

What: Don't hang.
Why: Because it should watch.

What do you see instead?

Hangs after the summary until Ctrl+C and prints one last summary after that.
So for the minimal example given before, that's one error message and two summaries in total.

The error is similar to this:

SyntaxError: Unexpected end of input
    at compileSourceTextModule (node:internal/modules/esm/utils:305:16)
    at ModuleLoader.moduleStrategy (node:internal/modules/esm/translators:111:18)
    at #translate (node:internal/modules/esm/loader:467:20)
    at afterLoad (node:internal/modules/esm/loader:523:29)
    at ModuleLoader.loadAndTranslate (node:internal/modules/esm/loader:528:12)
    at #getOrCreateModuleJobAfterResolve (node:internal/modules/esm/loader:565:36)
    at afterResolve (node:internal/modules/esm/loader:618:52)
    at ModuleLoader.getOrCreateModuleJob (node:internal/modules/esm/loader:624:12)
    at onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:643:32)
    at TracingChannel.tracePromise (node:diagnostics_channel:350:14)

Additional information

Idea: --test and --watch should have what --check does as an internal per file and change prerequisite.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions