Skip to content

Commit ca6c26f

Browse files
committed
fix: Await for persistVirtualDocuments result before finishing request
In previous implementation we did not await for the `persistVirtualDocuments()` result before completing the request This was done because the persistance was not mandatory for the request's result and doing it in parallel would be a good way to optimize timings But in some recent experiments we found a scenario where we would benefit from the `await` in order to some external code until the data is actually persisted Related PR: #1486
1 parent 6303b3c commit ca6c26f

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

packages/cozy-client/src/CozyClient.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1093,7 +1093,7 @@ client.query(Q('io.cozy.bills'))`)
10931093
async requestQuery(definition) {
10941094
const mainResponse = await this.chain.request(definition)
10951095

1096-
this.persistVirtualDocuments(definition, mainResponse.data)
1096+
await this.persistVirtualDocuments(definition, mainResponse.data)
10971097

10981098
if (!definition.includes) {
10991099
return mainResponse

packages/cozy-client/src/associations.spec.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ import { SCHEMA, TODO_1, TODO_2 } from './__tests__/fixtures'
77

88
describe('Associations', () => {
99
const requestHandler = jest.fn()
10-
const link = new CozyLink(requestHandler)
10+
const persistHandler = jest.fn()
11+
const link = new CozyLink(requestHandler, persistHandler)
1112
const client = new CozyClient({ links: [link], schema: SCHEMA })
1213

1314
const getTodo = id =>

0 commit comments

Comments
 (0)