Skip to content

na tsgo hangs in package dir without go.mod (tsgo spins in findGoMod) #316

@PaulRBerg

Description

@PaulRBerg

What happened?

Running na tsgo inside a workspace package directory can hang indefinitely (100% CPU) with no output.

This looks like @typescript/native-preview/tsgo spinning during startup when it can't find a go.mod in the current working directory (see stack trace below). I can reproduce the hang even when invoking the tsgo binary directly, so this is probably upstream, but na is currently a very easy way to hit it.

Repro

  • macOS 26.2 (arm64)
  • @antfu/ni v28.0.0
  • node v25.2.1
  • bun v1.3.5
  • @typescript/native-preview 7.0.0-dev.20251218.1

Minimal repro steps:

  1. In a monorepo with a workspace package (e.g. cli/) that has tsconfig.json but no go.mod in that directory.
  2. Install @typescript/native-preview.
  3. Run:
cd cli
na tsgo --help
# or
na tsgo --noEmit

Expected

tsgo prints help / completes typecheck and exits.

Actual

The process never terminates (busy loop).

Evidence (SIGQUIT stack trace)

After ~5s, sending SIGQUIT shows it stuck in github.com/microsoft/typescript-go/internal/repo.findGoMod calling os.Stat("go.mod"):

github.com/microsoft/typescript-go/internal/repo.findGoMod
  github.com/microsoft/typescript-go/internal/repo/paths.go:30
github.com/microsoft/typescript-go/internal/repo.init.0
  github.com/microsoft/typescript-go/internal/repo/paths.go:22

Workarounds

  • Run from a directory that contains a go.mod (even an empty one), or
  • Invoke tsgo from repo root and pass -p:
na tsgo --noEmit -p cli/tsconfig.json

Ask

Even if the root cause is upstream, would you accept a guard/diagnostic in na to detect this specific tsgo busy-hang scenario (e.g. if cmd == tsgo and there is no go.mod in cwd, print a warning suggesting -p or adding go.mod)?

If you’d prefer this to be filed upstream only, I can open an issue in microsoft/typescript-go instead.

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