Skip to content

Commit c6da575

Browse files
committed
fix: add err on endJobAsError
1 parent 76de2cf commit c6da575

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

services/admin/src/lib/elastic/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ async function bulk(data, refresh = false) {
200200

201201
let elasticResult;
202202
try {
203-
elasticResult = await elasticClient.bulk({ body: data, refresh });
203+
elasticResult = await elasticClient.bulk({ body: data, refresh }, { requestTimeout: 1 });
204204
} catch (err) {
205205
appLogger.error('[elastic]: Cannot bulk', err);
206206
throw err;

services/admin/src/lib/history/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ async function downloadInsertChangefilesHistoryProcess(jobConfig) {
9191
changefilesInfo = await getChangefiles(interval, startDate, endDate);
9292
} catch (err) {
9393
appLogger.error('[job][changefiles][history][download][insert]: Cannot get changefiles', err);
94-
await endJobAsError();
94+
await endJobAsError(err);
9595
appLogger.error('[job][changefiles][history][download][insert]: History download and insert changefile job is finish with an error', err);
9696
return;
9797
}
@@ -111,7 +111,7 @@ async function downloadInsertChangefilesHistoryProcess(jobConfig) {
111111
await downloadChangefile(changefilesInfo[i], interval);
112112
} catch (err) {
113113
appLogger.error(`[job][changefiles][history][download][insert]: Cannot download changefile [${changefilesInfo[i].filename}]`);
114-
await endJobAsError();
114+
await endJobAsError(err);
115115
appLogger.error('[job][changefiles][history][download][insert]: History download and insert changefile job is finish with an error', err);
116116
return;
117117
}
@@ -122,7 +122,7 @@ async function downloadInsertChangefilesHistoryProcess(jobConfig) {
122122
await insertHistoryDataUnpaywall(jobConfig);
123123
} catch (err) {
124124
appLogger.error(`[job][changefiles][history][download][insert]: Cannot insert changefile [${changefilesInfo[i].filename}]`);
125-
await endJobAsError();
125+
await endJobAsError(err);
126126
appLogger.error('[job][changefiles][history][download][insert]: History download and insert changefile job is finish with an error', err);
127127
return;
128128
}

services/admin/src/lib/update/index.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ const { deleteFile } = require('../files');
2626
const { getChangefiles } = require('../unpaywall/api');
2727
const { updateReportMail } = require('../mail');
2828

29-
async function endJobAsError() {
30-
await fail();
29+
async function endJobAsError(err) {
30+
await fail(err);
3131
const state = getState();
3232
await createReport(state);
3333
updateReportMail(state);
@@ -64,7 +64,7 @@ async function downloadSnapshotProcess() {
6464
filename = await downloadSnapshot();
6565
} catch (err) {
6666
appLogger.error('[job][snapshot][download]: Cannot download snapshot');
67-
await endJobAsError();
67+
await endJobAsError(err);
6868
appLogger.error('[job][snapshot][download]: download snapshot job is finished with an error', err);
6969
return;
7070
}
@@ -101,7 +101,7 @@ async function downloadInsertSnapshotProcess(jobConfig) {
101101
filename = await downloadSnapshot();
102102
} catch (err) {
103103
appLogger.error('[job][snapshot][download][insert]: Cannot download snapshot');
104-
await endJobAsError();
104+
await endJobAsError(err);
105105
appLogger.error('[job][snapshot][download][insert]: Download insert snapshot job is finished with an error', err);
106106
return;
107107
}
@@ -114,7 +114,7 @@ async function downloadInsertSnapshotProcess(jobConfig) {
114114
await insertDataUnpaywall(jobConfig);
115115
} catch (err) {
116116
appLogger.error(`[job][snapshot][download][insert]: Cannot insert the content of snapshot [${jobConfig.filename}]`);
117-
await endJobAsError();
117+
await endJobAsError(err);
118118
appLogger.error('[job][snapshot][download][insert]: Download insert snapshot job is finished with an error', err);
119119
return;
120120
}
@@ -170,7 +170,7 @@ async function downloadInsertChangefilesProcess(jobConfig) {
170170
changefilesInfo = await getChangefiles(interval, startDate, endDate);
171171
} catch (err) {
172172
appLogger.error('[job][changefiles][download][insert]: Cannot get changefiles', err);
173-
await endJobAsError();
173+
await endJobAsError(err);
174174
appLogger.error('[job][changefiles][download][insert]: Download and insert changefile job is finish with an error', err);
175175
return;
176176
}
@@ -191,7 +191,7 @@ async function downloadInsertChangefilesProcess(jobConfig) {
191191
await downloadChangefile(changefilesInfo[i], interval);
192192
} catch (err) {
193193
appLogger.error(`[job][changefiles][download][insert]: Cannot download changefile [${changefilesInfo[i].filename}]`);
194-
await endJobAsError();
194+
await endJobAsError(err);
195195
appLogger.error('[job][changefiles][download][insert]: Download and insert changefile job is finish with an error', err);
196196
return;
197197
}
@@ -202,7 +202,7 @@ async function downloadInsertChangefilesProcess(jobConfig) {
202202
await insertDataUnpaywall(jobConfig);
203203
} catch (err) {
204204
appLogger.error(`[job][changefiles][download][insert]: Cannot insert changefile [${changefilesInfo[i].filename}]`);
205-
await endJobAsError();
205+
await endJobAsError(err);
206206
appLogger.error('[job][changefiles][download][insert]: Download and insert changefile job is finish with an error', err);
207207
return;
208208
}
@@ -248,7 +248,7 @@ async function insertFileProcess(jobConfig) {
248248
await insertDataUnpaywall(jobConfig);
249249
} catch (err) {
250250
appLogger.error(`[job][${type}][insert]: Cannot insert ${type} [${jobConfig.filename}]`);
251-
await endJobAsError();
251+
await endJobAsError(err);
252252
appLogger.error(`[job][${type}][insert]: Insert changefile job is finish with an error`, err);
253253
return;
254254
}

0 commit comments

Comments
 (0)