fix(devtools): make sure we dont fail on null elements

This commit is contained in:
mgechev
2020-02-20 11:58:13 -08:00
committed by Sumit Arora
parent dca328e2ee
commit f454498274
2 changed files with 7 additions and 1 deletions
@@ -63,7 +63,8 @@ const insertElementProfile = (frames: ElementProfile[], position: ElementPositio
for (let i = 0; i < position.length - 1; i++) {
const pos = position[i];
if (!frames[pos]) {
debugger;
// console.warn('Unable to find parent node for', frames);
return;
}
frames = frames[pos].children;
}
@@ -28,6 +28,11 @@ const getLabel = (element: ElementProfile) => {
const addFrame = (nodes: FlamegraphNode[], elements: ElementProfile[]): number => {
let timeSpent = 0;
elements.forEach(element => {
// Possibly undefined because of the insertion
// on the backend.
if (!element) {
return;
}
const node: FlamegraphNode = {
value: element.directives.reduce((a, c) => a + c.lifecycle + c.changeDetection, 0),
label: getLabel(element),