Skip to content

Commit

Permalink
fix: Change timeout to get BI temporary token
Browse files Browse the repository at this point in the history
In some (too many) case, BI can take more than 30s to give response.
This leads to timeout error message to the user which occur in their
first connection or when renewing their connection.
And since these errors occur in the browser, they are not visible
in our usual connector error dashboard.

We saw that when BI is long to response, it takes usually 35s to 40s but
in most cases it takes 2s to 3s
  • Loading branch information
doubleface committed Nov 30, 2021
1 parent 92b6743 commit f0a0eff
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion packages/cozy-harvest-lib/src/services/budget-insight.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import logger from '../logger'

const DECOUPLED_ERROR = 'decoupled'
const ADDITIONAL_INFORMATION_NEEDED_ERROR = 'additionalInformationNeeded'
const TEMP_TOKEN_TIMOUT_S = 60

const getBIConnectionIdFromAccount = account =>
get(account, 'data.auth.bi.connId')
Expand Down Expand Up @@ -86,7 +87,7 @@ const createTemporaryToken = async ({ client, konnector, account }) => {
client,
jobResponse.data.attributes,
'result',
30 * 1000
TEMP_TOKEN_TIMOUT_S * 1000
)
return event.data.result
}
Expand Down
8 changes: 4 additions & 4 deletions packages/cozy-harvest-lib/src/services/budget-insight.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ describe('createOrUpdateBIConnection', () => {
_id: 'job-id-1337'
},
'result',
30000
60000
)
expect(createBIConnection).toHaveBeenCalledWith(
expect.any(Object),
Expand Down Expand Up @@ -350,7 +350,7 @@ describe('createOrUpdateBIConnection', () => {
_id: 'job-id-1337'
},
'result',
30000
60000
)
expect(createBIConnection).toHaveBeenCalledWith(
expect.any(Object),
Expand Down Expand Up @@ -393,7 +393,7 @@ describe('createOrUpdateBIConnection', () => {
_id: 'job-id-1337'
},
'result',
30000
60000
)
expect(createBIConnection).not.toHaveBeenCalled()
expect(updateBIConnection).toHaveBeenCalledWith(
Expand Down Expand Up @@ -440,7 +440,7 @@ describe('createOrUpdateBIConnection', () => {
_id: 'job-id-1337'
},
'result',
30000
60000
)
expect(updateBIConnection).not.toHaveBeenCalled()
expect(createBIConnection).toHaveBeenCalledWith(
Expand Down

0 comments on commit f0a0eff

Please sign in to comment.