Skip to content

Commit 9c1b99d

Browse files
authored
fix: keep sdk-commands start alive when the initial build fails (#1501)
In watch mode the file watcher and preview server outlive a failed re-build, but the initial build threw and killed the whole process — so opening a scene that already had a syntax error left no watcher alive to pick up the fix. Give the initial build the same report-and-recover contract as re-builds.
1 parent e704246 commit 9c1b99d

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

  • packages/@dcl/sdk-commands/src/logic

packages/@dcl/sdk-commands/src/logic/bundle.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -319,9 +319,19 @@ export async function bundleSingleProject(components: BundleComponents, options:
319319
}
320320
})
321321

322-
// Do initial build
323-
await context.rebuild()
324-
printProgressInfo(components.logger, `Bundle saved ${colors.bold(options.outputFile)}`)
322+
// Do initial build. A build error must not kill the process in watch mode:
323+
// the watcher above is already running and the preview server can still
324+
// start, so report the error and recover on the next file save — the same
325+
// contract as a failed re-build. Throwing here left `sdk-commands start`
326+
// dead when a scene was opened with a pre-existing syntax error, with no
327+
// watcher alive to pick up the fix.
328+
try {
329+
await context.rebuild()
330+
printProgressInfo(components.logger, `Bundle saved ${colors.bold(options.outputFile)}`)
331+
} catch (err: any) {
332+
/* istanbul ignore next */
333+
components.logger.error(err.toString())
334+
}
325335
printProgressInfo(components.logger, `The compiler is watching for changes`)
326336
} else {
327337
try {

0 commit comments

Comments
 (0)