fix: stop esbuild before exiting on a build error

This commit is contained in:
saberzero1 committed 2026-11-09 02:33:30 +01:00
1 parent 8a62b70b1d
commit 28fcb64720
3 files changed
+20 -1

No files matched your search

+5
View File
@@ -0,0 +1,5 @@
---
"@jackyzha0/quartz": patch
---
When a build stops on an error, Quartz stops esbuild before exiting. esbuild runs as a child process that writes to the same terminal; left running, it could print "fatal error: all goroutines are asleep - deadlock!" and a long goroutine dump after Quartz's error message.
+2
View File
@@ -428,6 +428,8 @@ export async function handleBuild(argv) {
`${styleText("red", "Failed to build Quartz.")} Check for syntax errors in your configuration or plugins.`,
)
console.log(`Reason: ${styleText("gray", err.message ?? String(err))}`)
// stop esbuild's child process first: it shares our stderr and outlives us otherwise
void esbuild.stop()
process.exit(1)
})
release()
+13 -1
View File
@@ -1,5 +1,6 @@
import { styleText } from "util"
import process from "process"
import esbuild from "esbuild"
import { isMainThread } from "workerpool"
import { isContentError, pluginErrorInfo, PluginErrorInfo } from "./pluginErrors"
import { knownProblemsFor } from "./diagnostics"
@@ -130,6 +131,17 @@ export function trace(msg: string, err: Error) {
} else {
// print and exit
console.error(traceMsg)
process.exit(1)
exitBuild(1)
}
}
/**
* Exit the build process. esbuild's service is a child process that shares our stderr; exiting
* while it has requests in flight (bundling component scripts, the CLI's build context) left it
* running without its parent, and it printed "fatal error: all goroutines are asleep - deadlock!"
* and a goroutine dump after Quartz's error. Stop it first.
*/
export function exitBuild(code: number): never {
void esbuild.stop()
process.exit(code)
}