Skip to content

Commit

Permalink
Gracefully handle expired ExecuteResponse when fetching profile (#7979)
Browse files Browse the repository at this point in the history
  • Loading branch information
bduffany authored Dec 2, 2024
1 parent 9217fa9 commit 488a178
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
10 changes: 8 additions & 2 deletions app/invocation/invocation_action_card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -433,7 +433,13 @@ export default class InvocationActionCardComponent extends React.Component<Props
return readProfile(response.body);
})
.then((profile) => 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 }));
}

Expand Down
4 changes: 4 additions & 0 deletions app/service/rpc_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down

0 comments on commit 488a178

Please sign in to comment.