Skip to content

Commit 21a72f5

Browse files
billyvgandrewshie-sentry
authored andcommitted
fix(releases): Fix when project not yet loaded yet and drawer is opened (#90829)
Fix when project is undefined, I *believe* this happens when we load the page and drawer immediately opens before projects are fetched.
1 parent b9c71dd commit 21a72f5

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

static/app/views/releases/utils/useReleaseDeploys.tsx

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
import {useEffect, useRef} from 'react';
2+
import {logger} from '@sentry/react';
3+
4+
import type {Project} from 'sentry/types/project';
15
import type {Deploy} from 'sentry/types/release';
26
import {useApiQuery} from 'sentry/utils/queryClient';
37
import useOrganization from 'sentry/utils/useOrganization';
@@ -12,12 +16,24 @@ export function useReleaseDeploys({
1216
}) {
1317
const organization = useOrganization();
1418
const project = useProjectFromSlug({organization, projectSlug});
19+
const prevProject = useRef<Project | undefined>(undefined);
20+
21+
useEffect(() => {
22+
if (!project) {
23+
logger.warn('Release: project undefined in useReleaseDeploys', {projectSlug});
24+
}
25+
if (project && !prevProject.current) {
26+
logger.warn('Release: project is now defined in useReleaseDeploys', {projectSlug});
27+
}
28+
prevProject.current = project;
29+
}, [project, projectSlug]);
30+
1531
return useApiQuery<Deploy[]>(
1632
[
1733
`/organizations/${organization.slug}/releases/${encodeURIComponent(release)}/deploys/`,
1834
{
1935
query: {
20-
project: project!.id, // Should be disabled if project is undefined
36+
project: project?.id, // Should be disabled if project is undefined
2137
},
2238
},
2339
],

0 commit comments

Comments
 (0)