combining `watch` and `onSuccess` crashes
- Dominant language
- TypeScript
- Stars
- 11.3k
- Forks
- 275
- PR merge metrics
- No merged PRs in 30d
Description
With an empty file `a.js`, I see the following
```
» npx tsup a.js --watch --onSuccess 'npm start'
CLI Building entry: a.js
CLI tsup v6.2.0
CLI Running in watch mode
CLI Target: node14
CJS Build start
CJS ⚡️ Build success in 36ms
CJS dist/a.js 0 B
CLI Watching for changes in "."
CLI Ignoring changes in "**/{.git,node_modules}/**" | "dist"
> tsup-sandbox@1.0.0 start
> node a.js
CLI Change detected: change a.js
CJS Build start
CJS ⚡️ Build success in 908ms
node:events:491
throw er; // Unhandled 'error' event
^
Error: spawn pgrep EAGAIN
at ChildProcess._handle.onexit (node:internal/child_process:283:19)
at onErrorNT (node:internal/child_process:476:16)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
Emitted 'error' event on ChildProcess instance at:
at ChildProcess._handle.onexit (node:internal/child_process:289:12)
at onErrorNT (node:internal/child_process:476:16)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
errno: -35,
code: 'EAGAIN',
syscall: 'spawn pgrep',
path: 'pgrep',
spawnargs: [ '-P', 71634 ]
}
Node.js v18.6.0
fatal error: all goroutines are asleep - deadlock!
goroutine 1 [semacquire]:
sync.runtime_Semacquire(0x140000021a0?)
runtime/sema.go:56 +0x2c
sync.(*WaitGroup).Wait(0x140000b42d8)
sync/waitgroup.go:136 +0x88
main.runService(0x1)
github.com/evanw/esbuild/cmd/esbuild/service.go:177 +0x3e4
main.main()
github.com/evanw/esbuild/cmd/esbuild/main.go:210 +0x1a8
goroutine 18 [chan receive]:
main.runService.func1()
github.com/evanw/esbuild/cmd/esbuild/service.go:110 +0x50
created by main.runService
github.com/evanw/esbuild/cmd/esbuild/service.go:108 +0x150
goroutine 19 [chan receive]:
main.(*serviceType).sendRequest(0x140000b42c0, {0x1031c70a0, 0x14000300b40})
github.com/evanw/esbuild/cmd/esbuild/service.go:203 +0xec
main.runService.func2()
github.com/evanw/esbuild/cmd/esbuild/service.go:132 +0x3c
created by main.runService
github.com/evanw/esbuild/cmd/esbuild/service.go:129 +0x268
```
`package.json`
```json
{
"name": "tsup-sandbox",
"version": "1.0.0",
"scripts": {
"start": "node a.js"
},
"devDependencies": {
"tsup": "^6.2.0"
}
}
```
When `a.js` is a long running process, like a server, it's also left running.
Contributor guide
Assessment
This issue has not been assessed yet.