Skip to content

Commit

Permalink
internal/content/telemetrygodev: handle missing null program charts
Browse files Browse the repository at this point in the history
Fixes the following exception during rendering:

TypeError: t.Charts is not iterable
    at charts.ts:40:33
    at charts.ts:155:1

When there is no data, the worker produces programs like:

Programs: [
  {Charts: null, ID: 'charts:cmd/compile', Name: 'cmd/compile'},
  ...
]

Change-Id: Ifb01e46a6bae51253b150668d1cfd657eaa04a90
Reviewed-on: https://go-review.googlesource.com/c/telemetry/+/592395
Reviewed-by: Robert Findley <[email protected]>
LUCI-TryBot-Result: Go LUCI <[email protected]>
  • Loading branch information
hyangah committed Jun 14, 2024
1 parent 8cad58b commit d924990
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
13 changes: 5 additions & 8 deletions internal/content/telemetrygodev/charts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@
*/

interface Page {
Charts: ChartData;
Charts: ChartData | null;
}

interface ChartData {
Programs: Program[];
Programs: Program[] | null;
}

interface Program {
ID: string;
Name: string;
Charts: Chart[];
Charts: Chart[] | null;
}

interface Chart {
Expand All @@ -36,11 +36,8 @@ declare const Page: Page;
import * as d3 from "d3";
import * as Plot from "@observablehq/plot";

for (const program of Page.Charts.Programs) {
for (const counter of program.Charts) {
if (!counter) {
continue;
}
for (const program of Page.Charts?.Programs || []) {
for (const counter of program?.Charts || []) {
switch (counter.Type) {
case "partition":
document
Expand Down
Loading

0 comments on commit d924990

Please sign in to comment.