MCPcopy Create free account
hub / github.com/angular/angular / executeWithInvalidateFallback

Function executeWithInvalidateFallback

packages/core/src/render3/hmr.ts:332–352  ·  view source on GitHub ↗

* Runs an HMR-related function and falls back to * invalidating the HMR data if it throws an error.

(
  importMeta: ImportMetaExtended | null,
  id: string | null,
  callback: () => void,
)

Source from the content-addressed store, hash-verified

330 * invalidating the HMR data if it throws an error.
331 */
332function executeWithInvalidateFallback(
333 importMeta: ImportMetaExtended | null,
334 id: string | null,
335 callback: () => void,
336) {
337 try {
338 callback();
339 } catch (e) {
340 const error = e as {message?: string; stack?: string};
341
342 // If we have all the necessary information and APIs to send off the invalidation
343 // request, send it before rethrowing so the dev server can decide what to do.
344 if (id !== null && error.message) {
345 const toLog = error.message + (error.stack ? '\n' + error.stack : '');
346 importMeta?.hot?.send?.('angular:invalidate', {id, message: toLog, error: true});
347 }
348
349 // Throw the error in case the page doesn't get refreshed.
350 throw e;
351 }
352}
353
354/**
355 * Replaces one LView in the tree with another one.

Callers 1

recreateLViewFunction · 0.85

Calls 2

callbackFunction · 0.50
sendMethod · 0.45

Tested by

no test coverage detected