Skip to content

Commit f0d6802

Browse files
committed
fix(build): keep the terminal recoverable if the phase line's first write fails
1 parent 15f725b commit f0d6802

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

packages/nuxt-cli/src/commands/build.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,15 @@ export default defineCommand({
7070
// reported below it rather than above.
7171
if (ctx.args.logLevel !== 'silent') {
7272
const reporter = createPhaseReporter({ heartbeat: HEARTBEAT_INTERVAL })
73-
const unsubscribe = progress.onUpdate(reporter.update)
73+
let unsubscribe: (() => void) | undefined
74+
// Assigned before subscribing, because subscribing reports the phase in
75+
// flight straight away: a first write that fails, on a pipe that has
76+
// already been closed, must still leave the terminal recoverable.
7477
stopReporting = () => {
75-
unsubscribe()
78+
unsubscribe?.()
7679
reporter.stop()
7780
}
81+
unsubscribe = progress.onUpdate(reporter.update)
7882
}
7983

8084
const kit = await loadKit(cwd)

0 commit comments

Comments
 (0)