Skip to content

Commit

Permalink
fix(@angular/build): always clear dev-server error overlay on non-err…
Browse files Browse the repository at this point in the history
…or result

Now that additional result object types can be returned from the build
system, the error overlay must be cleared on all non-error results. The
introduction of component update results and eventual incremental results
will now properly clear the error overlay after a successful build.

(cherry picked from commit 99192a7)
  • Loading branch information
clydin authored and alan-agius4 committed Nov 5, 2024
1 parent efb2232 commit ecaf870
Showing 1 changed file with 24 additions and 23 deletions.
47 changes: 24 additions & 23 deletions packages/angular/build/src/builders/dev-server/vite-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,20 +187,31 @@ export async function* serveWithVite(

// TODO: Switch this to an architect schedule call when infrastructure settings are supported
for await (const result of builderAction(browserOptions, context, extensions?.buildPlugins)) {
if (result.kind === ResultKind.Failure) {
if (result.errors.length && server) {
hadError = true;
server.ws.send({
type: 'error',
err: {
message: result.errors[0].text,
stack: '',
loc: result.errors[0].location ?? undefined,
},
});
}
continue;
}
// Clear existing error overlay on successful result
if (hadError && server) {
hadError = false;
// Send an empty update to clear the error overlay
server.ws.send({
'type': 'update',
updates: [],
});
}

switch (result.kind) {
case ResultKind.Failure:
if (result.errors.length && server) {
hadError = true;
server.ws.send({
type: 'error',
err: {
message: result.errors[0].text,
stack: '',
loc: result.errors[0].location ?? undefined,
},
});
}
continue;
case ResultKind.Full:
if (result.detail?.['htmlIndexPath']) {
htmlIndexPath = result.detail['htmlIndexPath'] as string;
Expand Down Expand Up @@ -253,16 +264,6 @@ export async function* serveWithVite(
continue;
}

// Clear existing error overlay on successful result
if (hadError && server) {
hadError = false;
// Send an empty update to clear the error overlay
server.ws.send({
'type': 'update',
updates: [],
});
}

// To avoid disconnecting the array objects from the option, these arrays need to be mutated instead of replaced.
let requiresServerRestart = false;
if (result.detail?.['externalMetadata']) {
Expand Down

0 comments on commit ecaf870

Please sign in to comment.