Skip to content

Commit bab596f

Browse files
authored
Merge pull request #1957 from line/fix/fix-infinite-loading-bug
fix infinite loading bug
2 parents 4bb3885 + 7939fb1 commit bab596f

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

apps/api/src/common/repositories/opensearch.repository.ts

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -217,12 +217,23 @@ export class OpensearchRepository {
217217
}
218218

219219
async updateData({ id, index, data }: UpdateDataDto) {
220-
await this.opensearchClient.update({
221-
id,
222-
index,
223-
body: { doc: data },
224-
refresh: true,
225-
});
220+
try {
221+
await this.opensearchClient.update({
222+
id,
223+
index,
224+
body: { doc: data },
225+
refresh: true,
226+
retry_on_conflict: 5,
227+
});
228+
} catch (error) {
229+
this.logger.error(`Error updating data: ${error}`);
230+
if (error?.meta?.body) {
231+
this.logger.error(
232+
`OpenSearch error details: ${JSON.stringify(error.meta.body, null, 2)}`,
233+
);
234+
}
235+
throw error;
236+
}
226237
}
227238

228239
async deleteBulkData({ ids, index }: DeleteBulkDataDto) {

0 commit comments

Comments
 (0)