Skip to content

Commit 9dda46f

Browse files
doublefacedoubleface
doubleface
authored andcommittedNov 30, 2021
fix: Change timeout to get BI temporary token
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

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed
 

‎packages/cozy-harvest-lib/src/services/budget-insight.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import logger from '../logger'
2828

2929
const DECOUPLED_ERROR = 'decoupled'
3030
const ADDITIONAL_INFORMATION_NEEDED_ERROR = 'additionalInformationNeeded'
31+
const TEMP_TOKEN_TIMOUT_S = 60
3132

3233
const getBIConnectionIdFromAccount = account =>
3334
get(account, 'data.auth.bi.connId')
@@ -86,7 +87,7 @@ const createTemporaryToken = async ({ client, konnector, account }) => {
8687
client,
8788
jobResponse.data.attributes,
8889
'result',
89-
30 * 1000
90+
TEMP_TOKEN_TIMOUT_S * 1000
9091
)
9192
return event.data.result
9293
}

‎packages/cozy-harvest-lib/src/services/budget-insight.spec.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ describe('createOrUpdateBIConnection', () => {
321321
_id: 'job-id-1337'
322322
},
323323
'result',
324-
30000
324+
60000
325325
)
326326
expect(createBIConnection).toHaveBeenCalledWith(
327327
expect.any(Object),
@@ -350,7 +350,7 @@ describe('createOrUpdateBIConnection', () => {
350350
_id: 'job-id-1337'
351351
},
352352
'result',
353-
30000
353+
60000
354354
)
355355
expect(createBIConnection).toHaveBeenCalledWith(
356356
expect.any(Object),
@@ -393,7 +393,7 @@ describe('createOrUpdateBIConnection', () => {
393393
_id: 'job-id-1337'
394394
},
395395
'result',
396-
30000
396+
60000
397397
)
398398
expect(createBIConnection).not.toHaveBeenCalled()
399399
expect(updateBIConnection).toHaveBeenCalledWith(
@@ -440,7 +440,7 @@ describe('createOrUpdateBIConnection', () => {
440440
_id: 'job-id-1337'
441441
},
442442
'result',
443-
30000
443+
60000
444444
)
445445
expect(updateBIConnection).not.toHaveBeenCalled()
446446
expect(createBIConnection).toHaveBeenCalledWith(

0 commit comments

Comments
 (0)
Please sign in to comment.