Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

increase the timeouts for report API calls to 600 seconds #1412

Merged
merged 4 commits into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# FOSSA CLI Changelog

## Unreleased

- Reports: Increase the timeout when hitting the report generation API endpoint

## v3.9.12
- `--detect-dynamic`: Fix deb tatic parsing ([#1401](https://github.com/fossas/fossa-cli/pull/1401)).

Expand Down
6 changes: 5 additions & 1 deletion src/Control/Carrier/FossaApiClient/Internal/FossaAPIV1.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1183,6 +1183,8 @@ getAttributionJson apiOpts ProjectRevision{..} = fossaReq $ do
=: True
<> "dependencyInfoOptions[]"
=: packageDownloadUrl
-- Large reports can take over a minute to generate, so increase the timeout to 10 minutes
<> responseTimeoutSeconds 600
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems fine, but I think it would be good to have a top-level defaultResponseTimeout and refer to that rather than write 600 in both places.

Copy link
Contributor Author

@spatten spatten Apr 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default is actually 30 seconds (from the library), and we are overriding it here.

The default comes from the Network.HTTP.Req library. Search for "responseTimeout" on this page: https://hackage.haskell.org/package/req-3.13.2/docs/Network-HTTP-Req.html#g:12

orgId <- organizationId <$> getOrganization apiOpts
response <- req GET (attributionEndpoint baseUrl orgId (Locator "custom" projectName (Just projectRevision)) ReportJson) NoReqBody jsonResponse opts
pure (responseBody response)
Expand All @@ -1197,7 +1199,9 @@ getAttribution apiOpts revision ReportJson = fossaReq $ do
jsonValue <- getAttributionJson apiOpts revision
pure . decodeUtf8 $ Aeson.encode jsonValue
getAttribution apiOpts ProjectRevision{..} format = fossaReq $ do
(baseUrl, opts) <- useApiOpts apiOpts
(baseUrl, baseOpts) <- useApiOpts apiOpts
-- Large reports can take over a minute to generate, so increase the timeout to 10 minutes
let opts = baseOpts <> responseTimeoutSeconds 600

orgId <- organizationId <$> getOrganization apiOpts
response <- req GET (attributionEndpoint baseUrl orgId (Locator "custom" projectName (Just projectRevision)) format) NoReqBody bsResponse opts
Expand Down
Loading