Skip to content

Commit 1dcc950

Browse files
authored
Merge pull request #394 from bitfinexcom/staging
Release version to master
2 parents 5b90d3c + 0fc54d2 commit 1dcc950

File tree

7 files changed

+60
-160
lines changed

7 files changed

+60
-160
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "bfx-report",
3-
"version": "4.10.6",
3+
"version": "4.10.7",
44
"description": "Reporting tool",
55
"main": "worker.js",
66
"license": "Apache-2.0",

test/helpers/helpers.core.js

+34-26
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,55 @@
11
'use strict'
22

3-
const { promisify } = require('util')
43
const path = require('path')
5-
const fs = require('fs')
64

7-
const readdir = promisify(fs.readdir)
8-
const unlink = promisify(fs.unlink)
9-
const mkdir = promisify(fs.mkdir)
5+
const {
6+
readdir,
7+
mkdir,
8+
rm
9+
} = require('node:fs/promises')
1010

1111
const rmDB = async (
1212
dir,
13-
exclude = ['.gitkeep'],
14-
isThrownError
13+
exclude = ['.gitkeep']
1514
) => {
1615
try {
17-
const files = await readdir(dir)
18-
const promisesArr = files.map((file) => {
19-
if (exclude.every(exFile => exFile !== file)) {
20-
return unlink(path.join(dir, file))
16+
const files = await readdir(
17+
dir,
18+
{ withFileTypes: true }
19+
)
20+
21+
for (const dirent of files) {
22+
const { name } = dirent
23+
24+
if (
25+
!dirent.isFile() ||
26+
exclude.some((exFile) => exFile === name)
27+
) {
28+
continue
2129
}
2230

23-
return null
24-
})
25-
26-
const res = await Promise.all(promisesArr)
27-
28-
return res
29-
} catch (err) {
30-
if (!isThrownError) {
31-
return
31+
const filePath = path.join(dir, name)
32+
await rm(
33+
filePath,
34+
{
35+
force: true,
36+
maxRetries: 5,
37+
recursive: true,
38+
retryDelay: 200
39+
}
40+
)
3241
}
33-
34-
throw err
42+
} catch (err) {
43+
console.log(err)
3544
}
3645
}
3746

3847
const rmAllFiles = async (dir, exclude) => {
3948
try {
40-
await rmDB(dir, exclude, true)
49+
await rmDB(dir, exclude)
50+
await mkdir(dir, { recursive: true })
4151
} catch (err) {
42-
if (err.syscall === 'scandir') {
43-
await mkdir(dir)
44-
}
52+
console.log(err)
4553
}
4654
}
4755

workers/api.service.report.wrk.js

-9
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,6 @@ class WrkReportServiceApi extends WrkApi {
7373
loadDIConfig (cont = container) {
7474
const conf = this.conf[this.group]
7575

76-
/**
77-
* @deprecated isAddedUniqueEndingToCsvName
78-
* Keep for back compatibility
79-
*/
80-
conf.isAddedUniqueEndingToReportFileName = (
81-
conf.isAddedUniqueEndingToReportFileName ??
82-
conf.isAddedUniqueEndingToCsvName
83-
)
84-
8576
this.container = cont
8677

8778
diConfig(conf, this.ctx.root)

workers/loc.api/generate-report-file/index.js

+1-7
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,7 @@ const _getReportFileStoreStatus = async ({
4141
return {
4242
isSaveLocaly: true,
4343
localReportFolderPath,
44-
remoteReportUrn,
45-
46-
/**
47-
* @deprecated fields
48-
*/
49-
localCsvFolderPath: localReportFolderPath,
50-
remoteCsvUrn: remoteReportUrn
44+
remoteReportUrn
5145
}
5246
}
5347

workers/loc.api/helpers/api-errors-testers.js

+14-2
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,11 @@ const isEAiAgainError = (err) => {
4848
}
4949

5050
const isEConnRefusedError = (err) => {
51-
return /ECONNREFUSED/i.test(_getErrorString(err))
51+
return /(ECONNREFUSED)|(ERR_CONNECTION_REFUSED)/i.test(_getErrorString(err))
52+
}
53+
54+
const isEConnClosedError = (err) => {
55+
return /ERR_CONNECTION_CLOSED/i.test(_getErrorString(err))
5256
}
5357

5458
const isENotFoundError = (err) => {
@@ -71,6 +75,10 @@ const isTempUnavailableError = (err) => {
7175
return /temporarily_unavailable/i.test(_getErrorString(err))
7276
}
7377

78+
const isBadGatewayError = (err) => {
79+
return /Bad Gateway/i.test(_getErrorString(err))
80+
}
81+
7482
const isForbiddenError = (err) => {
7583
return /forbidden/i.test(_getErrorString(err))
7684
}
@@ -87,11 +95,13 @@ const isENetError = (err) => (
8795
isNodeFetchTimeoutError(err) ||
8896
isEAiAgainError(err) ||
8997
isEConnRefusedError(err) ||
98+
isEConnClosedError(err) ||
9099
isENotFoundError(err) ||
91100
isESocketTimeoutError(err) ||
92101
isEHostUnreachError(err) ||
93102
isEProtoError(err) ||
94-
isTempUnavailableError(err)
103+
isTempUnavailableError(err) ||
104+
isBadGatewayError(err)
95105
)
96106

97107
module.exports = {
@@ -106,11 +116,13 @@ module.exports = {
106116
isNodeFetchTimeoutError,
107117
isEAiAgainError,
108118
isEConnRefusedError,
119+
isEConnClosedError,
109120
isENotFoundError,
110121
isESocketTimeoutError,
111122
isEHostUnreachError,
112123
isEProtoError,
113124
isTempUnavailableError,
125+
isBadGatewayError,
114126
isENetError,
115127
isForbiddenError,
116128
isMaintenanceError

workers/loc.api/helpers/index.js

+10
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,13 @@ const {
3434
isNodeFetchTimeoutError,
3535
isEAiAgainError,
3636
isEConnRefusedError,
37+
isEConnClosedError,
3738
isENotFoundError,
3839
isESocketTimeoutError,
40+
isEHostUnreachError,
41+
isEProtoError,
42+
isTempUnavailableError,
43+
isBadGatewayError,
3944
isENetError,
4045
isForbiddenError,
4146
isMaintenanceError
@@ -81,8 +86,13 @@ module.exports = {
8186
isNodeFetchTimeoutError,
8287
isEAiAgainError,
8388
isEConnRefusedError,
89+
isEConnClosedError,
8490
isENotFoundError,
8591
isESocketTimeoutError,
92+
isEHostUnreachError,
93+
isEProtoError,
94+
isTempUnavailableError,
95+
isBadGatewayError,
8696
isENetError,
8797
isForbiddenError,
8898
isMaintenanceError,

0 commit comments

Comments
 (0)