Skip to content

--on-success hook is flaky #763

@lexuzieel

Description

@lexuzieel

Reproduction link or steps

When I create a minimal file src/index.ts:

const main = async () => {
  console.log("main 1 2 3"); // I appended "1 2 3" here and it autosaved
};

await main();

export {};

and try to run it like so:

tsdown src/index.ts --watch --on-success 'node dist/index.mjs'

sometimes it gets triggered twice due to automatic saving I have enabled in vscode:

ℹ Found .../src/index.ts changed, rebuilding...
ℹ dist/index.mjs  0.12 kB │ gzip: 0.12 kB
ℹ 1 files, total: 0.12 kB
✔ Rebuilt in 11ms.
main 1 2 3
main 1 2 3

The issue I am trying to solve:

I want to watch changes and restart the app in a single command without replying on 3rd party tooling or hooks

What is expected?

Hook is triggered exactly once consistently after each build

What is actually happening?

I get duplicated output (program is executed twice):

ℹ Found .../src/index.ts changed, rebuilding...
ℹ dist/index.mjs  0.12 kB │ gzip: 0.12 kB
ℹ 1 files, total: 0.12 kB
✔ Rebuilt in 11ms.
main 1 2 3
main 1 2 3

Any additional comments?

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions