mirror of
https://github.com/angular/angular
synced 2026-05-24 09:28:37 +00:00
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 https://github.com/angular/angular-cli/issues/29695. PR Close #60067
This commit is contained in:
parent
9c5a6a6442
commit
ebfbaeba54
1 changed files with 4 additions and 3 deletions
|
|
@ -308,12 +308,13 @@ function executeWithInvalidateFallback(
|
|||
try {
|
||||
callback();
|
||||
} catch (e) {
|
||||
const errorMessage = (e as {message?: string}).message;
|
||||
const error = e as {message?: string; stack?: string};
|
||||
|
||||
// If we have all the necessary information and APIs to send off the invalidation
|
||||
// request, send it before rethrowing so the dev server can decide what to do.
|
||||
if (id !== null && errorMessage) {
|
||||
importMeta?.hot?.send?.('angular:invalidate', {id, message: errorMessage, error: true});
|
||||
if (id !== null && error.message) {
|
||||
const toLog = error.message + (error.stack ? '\n' + error.stack : '');
|
||||
importMeta?.hot?.send?.('angular:invalidate', {id, message: toLog, error: true});
|
||||
}
|
||||
|
||||
// Throw the error in case the page doesn't get refreshed.
|
||||
|
|
|
|||
Loading…
Reference in a new issue