Skip to content

Commit ecaf870

Browse files
clydinalan-agius4
authored andcommitted
fix(@angular/build): always clear dev-server error overlay on non-error 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)
1 parent efb2232 commit ecaf870

File tree

1 file changed

+24
-23
lines changed

1 file changed

+24
-23
lines changed

packages/angular/build/src/builders/dev-server/vite-server.ts

+24-23
Original file line numberDiff line numberDiff line change
@@ -187,20 +187,31 @@ export async function* serveWithVite(
187187

188188
// TODO: Switch this to an architect schedule call when infrastructure settings are supported
189189
for await (const result of builderAction(browserOptions, context, extensions?.buildPlugins)) {
190+
if (result.kind === ResultKind.Failure) {
191+
if (result.errors.length && server) {
192+
hadError = true;
193+
server.ws.send({
194+
type: 'error',
195+
err: {
196+
message: result.errors[0].text,
197+
stack: '',
198+
loc: result.errors[0].location ?? undefined,
199+
},
200+
});
201+
}
202+
continue;
203+
}
204+
// Clear existing error overlay on successful result
205+
if (hadError && server) {
206+
hadError = false;
207+
// Send an empty update to clear the error overlay
208+
server.ws.send({
209+
'type': 'update',
210+
updates: [],
211+
});
212+
}
213+
190214
switch (result.kind) {
191-
case ResultKind.Failure:
192-
if (result.errors.length && server) {
193-
hadError = true;
194-
server.ws.send({
195-
type: 'error',
196-
err: {
197-
message: result.errors[0].text,
198-
stack: '',
199-
loc: result.errors[0].location ?? undefined,
200-
},
201-
});
202-
}
203-
continue;
204215
case ResultKind.Full:
205216
if (result.detail?.['htmlIndexPath']) {
206217
htmlIndexPath = result.detail['htmlIndexPath'] as string;
@@ -253,16 +264,6 @@ export async function* serveWithVite(
253264
continue;
254265
}
255266

256-
// Clear existing error overlay on successful result
257-
if (hadError && server) {
258-
hadError = false;
259-
// Send an empty update to clear the error overlay
260-
server.ws.send({
261-
'type': 'update',
262-
updates: [],
263-
});
264-
}
265-
266267
// To avoid disconnecting the array objects from the option, these arrays need to be mutated instead of replaced.
267268
let requiresServerRestart = false;
268269
if (result.detail?.['externalMetadata']) {

0 commit comments

Comments
 (0)