@@ -2,7 +2,7 @@ import dayjs from "dayjs";
2
2
import { useSession } from "next-auth/react" ;
3
3
import { IssueLabelApiResponse } from "pages/api/issue/[label]" ;
4
4
import useSWR from "swr" ;
5
- import { isFailure , IsJobInProgress } from "../lib/JobClassifierUtil" ;
5
+ import { IsJobInProgress } from "../lib/JobClassifierUtil" ;
6
6
import { isFailedJob , transformJobName } from "../lib/jobUtils" ;
7
7
import { IssueData , JobData } from "../lib/types" ;
8
8
import CopyLink from "./CopyLink" ;
@@ -206,18 +206,18 @@ function formatUnstableJobBody() {
206
206
}
207
207
208
208
function UnstableJob ( { job, label } : { job : JobData ; label : string } ) {
209
- const swrKey = isFailure ( job . conclusion ) ? `/api/issue/${ label } ` : null ;
210
- const { data : issues } = useSWR < IssueLabelApiResponse > ( swrKey , fetcher , {
211
- // Set a 60s cache for the request, so that lots of tooltip hovers don't
212
- // spam the backend. Since actually mutating the state (through filing a
213
- // disable issue) is a pretty heavy operation, 60s of staleness is fine.
214
- dedupingInterval : 60 * 1000 ,
215
- refreshInterval : 60 * 1000 , // refresh every minute
216
- } ) ;
217
-
218
- if ( ! isFailure ( job . conclusion ) ) {
219
- return null ;
220
- }
209
+ const swrKey = `/api/issue/${ label } ` ;
210
+ const { data : issues , isLoading } = useSWR < IssueLabelApiResponse > (
211
+ swrKey ,
212
+ fetcher ,
213
+ {
214
+ // Set a 60s cache for the request, so that lots of tooltip hovers don't
215
+ // spam the backend. Since actually mutating the state (through filing a
216
+ // disable issue) is a pretty heavy operation, 60s of staleness is fine.
217
+ dedupingInterval : 60 * 1000 ,
218
+ refreshInterval : 60 * 1000 , // refresh every minute
219
+ }
220
+ ) ;
221
221
222
222
const jobName = transformJobName ( job . name ) ;
223
223
// Ignore invalid job name
@@ -226,10 +226,16 @@ function UnstableJob({ job, label }: { job: JobData; label: string }) {
226
226
}
227
227
228
228
// If we don't yet have any data, show a loading state.
229
- if ( issues === undefined ) {
229
+ if ( isLoading ) {
230
230
return < span > checking for disable jobs</ span > ;
231
231
}
232
232
233
+ if ( issues === undefined ) {
234
+ // Usually this means that it's loading but add this check just in case it
235
+ // actually returns undefined somehow and hide it from users.
236
+ return null ;
237
+ }
238
+
233
239
// At this point, we should show something. Search the existing disable issues
234
240
// for a matching one.
235
241
const issueTitle = `UNSTABLE ${ jobName } ` ;
@@ -238,6 +244,11 @@ function UnstableJob({ job, label }: { job: JobData; label: string }) {
238
244
const matchingIssues = issues . filter ( ( issue ) =>
239
245
issueTitle . includes ( issue . title )
240
246
) ;
247
+
248
+ if ( matchingIssues . length == 0 ) {
249
+ return null ;
250
+ }
251
+
241
252
const repo = job . repo ?? "pytorch/pytorch" ;
242
253
243
254
return (
0 commit comments