MCPcopy
hub / github.com/angular/angular / executeWithInvalidateFallback

Function executeWithInvalidateFallback

packages/core/src/render3/hmr.ts:326–346  ·  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

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

Used in the wild real call sites across dependent graphs

searching dependent graphs…