From 488a17845de1d862c0081691e8bf29a13b922efb Mon Sep 17 00:00:00 2001 From: Brandon Duffany Date: Mon, 2 Dec 2024 08:14:53 -0800 Subject: [PATCH] Gracefully handle expired ExecuteResponse when fetching profile (#7979) --- app/invocation/invocation_action_card.tsx | 10 ++++++++-- app/service/rpc_service.ts | 4 ++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/app/invocation/invocation_action_card.tsx b/app/invocation/invocation_action_card.tsx index 23450e04b7a..a07d842ea38 100644 --- a/app/invocation/invocation_action_card.tsx +++ b/app/invocation/invocation_action_card.tsx @@ -30,7 +30,7 @@ import capabilities from "../capabilities/capabilities"; import { getErrorReason } from "../util/rpc"; import rpc_service from "../service/rpc_service"; import { execution_stats } from "../../proto/execution_stats_ts_proto"; -import { BuildBuddyError } from "../util/errors"; +import { BuildBuddyError, HTTPStatusError } from "../util/errors"; import { Profile, readProfile } from "../trace/trace_events"; import TraceViewer from "../trace/trace_viewer"; import Spinner from "../components/spinner/spinner"; @@ -433,7 +433,13 @@ export default class InvocationActionCardComponent extends React.Component this.setState({ profile })) - .catch((e) => errorService.handleError(e)) + .catch((e) => { + // Ignore NotFound + if (e instanceof HTTPStatusError && e.code === 404) { + return; + } + errorService.handleError(e); + }) .finally(() => this.setState({ profileLoading: false })); } diff --git a/app/service/rpc_service.ts b/app/service/rpc_service.ts index c28a798ac99..7df91b0f8d2 100644 --- a/app/service/rpc_service.ts +++ b/app/service/rpc_service.ts @@ -196,6 +196,10 @@ class RpcService { /** * Performs a cancelable fetch request to the /file/download endpoint. * + * If the server returns a status code in the response other than 2XX, the + * returned promise rejects with a HTTPStatusError, which contains the + * response code and body. + * * Canceling the returned promise prevents it from completing and also cancels * the underlying network request. */