@nexrender/core 1.60.8 → 1.60.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/src/tasks/download.js +9 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nexrender/core",
|
|
3
|
-
"version": "1.60.
|
|
3
|
+
"version": "1.60.10",
|
|
4
4
|
"main": "src/index.js",
|
|
5
5
|
"author": "Inlife",
|
|
6
6
|
"homepage": "https://www.nexrender.com",
|
|
@@ -43,5 +43,5 @@
|
|
|
43
43
|
"publishConfig": {
|
|
44
44
|
"access": "public"
|
|
45
45
|
},
|
|
46
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "248afa43b4467ef3ae61bdbe74392d159e41f386"
|
|
47
47
|
}
|
package/src/tasks/download.js
CHANGED
|
@@ -9,11 +9,13 @@ const mime = require('mime-types')
|
|
|
9
9
|
const {expandEnvironmentVariables} = require('../helpers/path')
|
|
10
10
|
const { withTimeout } = require('../helpers/timeout');
|
|
11
11
|
|
|
12
|
-
const NEXRENDER_DOWNLOAD_TIMEOUT = process.env.NEXRENDER_DOWNLOAD_TIMEOUT || 3 * 60 * 1000; // 3 minutes timeout by default
|
|
12
|
+
const NEXRENDER_DOWNLOAD_TIMEOUT = Number(process.env.NEXRENDER_DOWNLOAD_TIMEOUT) || 3 * 60 * 1000; // 3 minutes timeout by default
|
|
13
13
|
|
|
14
14
|
const download = (job, settings, asset) => {
|
|
15
15
|
if (asset.type == 'data') return Promise.resolve();
|
|
16
16
|
|
|
17
|
+
settings.logger.log(`[${job.uid}] > Downloading asset ${asset.src}...`);
|
|
18
|
+
|
|
17
19
|
// eslint-disable-next-line
|
|
18
20
|
const uri = global.URL ? new URL(asset.src) : url.parse(asset.src)
|
|
19
21
|
const protocol = uri.protocol.replace(/:$/, '');
|
|
@@ -88,7 +90,11 @@ const download = (job, settings, asset) => {
|
|
|
88
90
|
|
|
89
91
|
/* TODO: maybe move to external package ?? */
|
|
90
92
|
const src = asset.src
|
|
91
|
-
return
|
|
93
|
+
return withTimeout(
|
|
94
|
+
fetch(src, {
|
|
95
|
+
...asset.params,
|
|
96
|
+
timeout: NEXRENDER_DOWNLOAD_TIMEOUT
|
|
97
|
+
})
|
|
92
98
|
.then(res => res.ok ? res : Promise.reject(new Error(`Unable to download file ${src}`)))
|
|
93
99
|
.then(res => {
|
|
94
100
|
// Set a file extension based on content-type header if not already set
|
|
@@ -120,7 +126,7 @@ const download = (job, settings, asset) => {
|
|
|
120
126
|
.on('error', errorHandler)
|
|
121
127
|
.on('finish', resolve)
|
|
122
128
|
}), NEXRENDER_DOWNLOAD_TIMEOUT, 'Download timed out for asset ' + asset.src)
|
|
123
|
-
})
|
|
129
|
+
}), NEXRENDER_DOWNLOAD_TIMEOUT, 'Download timed out for asset ' + asset.src)
|
|
124
130
|
|
|
125
131
|
case 'file':
|
|
126
132
|
const filepath = uri2path(expandEnvironmentVariables(asset.src))
|