MCPcopy
hub / github.com/triggerdotdev/trigger.dev / useRunDetails

Function useRunDetails

packages/react/src/runs.ts:19–54  ·  view source on GitHub ↗
(
  runId: string | undefined,
  options?: RunDetailOptions
)

Source from the content-addressed store, hash-verified

17export type UseRunDetailsResult = UseQueryResult<GetRun>;
18
19export function useRunDetails(
20 runId: string | undefined,
21 options?: RunDetailOptions
22): UseRunDetailsResult {
23 const { apiUrl, publicApiKey, queryClient } = useTriggerProvider();
24
25 const { refreshIntervalMs: refreshInterval, ...otherOptions } = options || {};
26
27 const url = urlWithSearchParams(`${apiUrl}/api/v2/runs/${runId}`, otherOptions);
28
29 return useQuery(
30 {
31 queryKey: [`triggerdotdev-run-${runId}`],
32 queryFn: async () => {
33 return await zodfetch(GetRunSchema, url, {
34 method: "GET",
35 headers: {
36 Authorization: `Bearer ${publicApiKey}`,
37 },
38 });
39 },
40 enabled: !!runId,
41 refetchInterval: (data) => {
42 if (data?.status && runResolvedStatuses.includes(data.status)) {
43 return false;
44 }
45 if (refreshInterval !== undefined) {
46 return Math.max(refreshInterval, 500);
47 }
48
49 return defaultRefreshInterval;
50 },
51 },
52 queryClient
53 );
54}

Callers 2

useEventRunDetailsFunction · 0.90
ReactHooksFunction · 0.90

Calls 4

useTriggerProviderFunction · 0.90
urlWithSearchParamsFunction · 0.90
zodfetchFunction · 0.90
maxMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…