Skip to content

Commit e601bdc

Browse files
crisbetokirjs
authored andcommitted
fix(core): capture stack for HMR errors (#60067)
Currently we send the `message` of an error thrown during HMR. That's usually not enough so now we also capture the stack trace. Relates to angular/angular-cli#29695. PR Close #60067
1 parent 4853129 commit e601bdc

File tree

1 file changed

+4
-3
lines changed
  • packages/core/src/render3

1 file changed

+4
-3
lines changed

packages/core/src/render3/hmr.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -308,12 +308,13 @@ function executeWithInvalidateFallback(
308308
try {
309309
callback();
310310
} catch (e) {
311-
const errorMessage = (e as {message?: string}).message;
311+
const error = e as {message?: string; stack?: string};
312312

313313
// If we have all the necessary information and APIs to send off the invalidation
314314
// request, send it before rethrowing so the dev server can decide what to do.
315-
if (id !== null && errorMessage) {
316-
importMeta?.hot?.send?.('angular:invalidate', {id, message: errorMessage, error: true});
315+
if (id !== null && error.message) {
316+
const toLog = error.message + (error.stack ? '\n' + error.stack : '');
317+
importMeta?.hot?.send?.('angular:invalidate', {id, message: toLog, error: true});
317318
}
318319

319320
// Throw the error in case the page doesn't get refreshed.

0 commit comments

Comments
 (0)