@nexrender/core 1.49.0 → 1.49.2

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nexrender/core",
3
- "version": "1.49.0",
3
+ "version": "1.49.2",
4
4
  "main": "src/index.js",
5
5
  "author": "Inlife",
6
6
  "homepage": "https://www.nexrender.com",
@@ -38,5 +38,5 @@
38
38
  "publishConfig": {
39
39
  "access": "public"
40
40
  },
41
- "gitHead": "09d4fa21b61322d4c208d1f95c4271a1d1bb7f62"
41
+ "gitHead": "c09f9f1a34418dd6574e958a6256633cb3ed614d"
42
42
  }
package/src/index.js CHANGED
@@ -91,6 +91,9 @@ const init = (settings) => {
91
91
 
92
92
  onInstanceSpawn: undefined,
93
93
 
94
+ // amount of seconds before job will be marked as "stuck"
95
+ maxUpdateTimeout: process.env.NEXRENDER_MAX_UPDATE_TIMEOUT || 60,
96
+
94
97
  __initialized: true,
95
98
  }, settings, {
96
99
  binary: binaryUser || binaryAuto,
@@ -186,6 +186,8 @@ Estimated date of change to the new behavior: 2023-06-01.\n`);
186
186
  renderStopwatch = Date.now();
187
187
 
188
188
  let timeoutID = 0;
189
+ let updateTimeout = 0;
190
+ let updateTimeoutInterval = null;
189
191
 
190
192
  if (settings.debug) {
191
193
  settings.logger.log(`[${job.uid}] spawning aerender process: ${settings.binary} ${params.join(' ')}`);
@@ -201,6 +203,7 @@ Estimated date of change to the new behavior: 2023-06-01.\n`);
201
203
 
202
204
  instance.on('error', err => {
203
205
  clearTimeout(timeoutID);
206
+ clearInterval(updateTimeoutInterval);
204
207
  settings.trackSync('Job Render Failed', { job_id: job.uid, error: 'aerender_spawn_error' });
205
208
  return reject(new Error(`Error starting aerender process: ${err}`));
206
209
  });
@@ -208,17 +211,34 @@ Estimated date of change to the new behavior: 2023-06-01.\n`);
208
211
  instance.stdout.on('data', (data) => {
209
212
  output.push(parse(data.toString('utf8')));
210
213
  (settings.verbose && settings.logger.log(data.toString('utf8')));
214
+ updateTimeout = Date.now()
211
215
  });
212
216
 
213
217
  instance.stderr.on('data', (data) => {
214
218
  output.push(data.toString('utf8'));
215
219
  (settings.verbose && settings.logger.log(data.toString('utf8')));
220
+ updateTimeout = Date.now()
216
221
  });
217
222
 
223
+ updateTimeoutInterval = setInterval(() => {
224
+ if (projectStart === null) return;
225
+
226
+ const now = Date.now()
227
+ if (now - updateTimeout > settings.maxUpdateTimeout * 1000) {
228
+ clearInterval(updateTimeoutInterval);
229
+ clearTimeout(timeoutID);
230
+ settings.trackSync('Job Render Failed', { job_id: job.uid, error: 'aerender_no_update' });
231
+ reject(new Error(`No update from aerender for ${settings.maxUpdateTimeout} seconds`));
232
+ instance.kill('SIGINT');
233
+ }
234
+ }, 5000)
235
+
218
236
  if (settings.maxRenderTimeout && settings.maxRenderTimeout > 0) {
219
237
  const timeout = 1000 * settings.maxRenderTimeout;
220
238
  timeoutID = setTimeout(
221
239
  () => {
240
+ clearInterval(updateTimeoutInterval);
241
+ clearTimeout(timeoutID);
222
242
  settings.trackSync('Job Render Failed', { job_id: job.uid, error: 'aerender_timeout' });
223
243
  reject(new Error(`Maximum rendering time exceeded`));
224
244
  instance.kill('SIGINT');
@@ -245,6 +265,7 @@ Estimated date of change to the new behavior: 2023-06-01.\n`);
245
265
  error: 'aerender_exit_code',
246
266
  });
247
267
 
268
+ clearInterval(updateTimeoutInterval);
248
269
  clearTimeout(timeoutID);
249
270
  return reject(new Error(outputStr || 'aerender.exe failed to render the output into the file due to an unknown reason'));
250
271
  }
@@ -263,6 +284,7 @@ Estimated date of change to the new behavior: 2023-06-01.\n`);
263
284
  job_render_time: renderTime,
264
285
  })
265
286
 
287
+ clearInterval(updateTimeoutInterval);
266
288
  clearTimeout(timeoutID);
267
289
  return resolve(job)
268
290
  }
@@ -292,6 +314,7 @@ Estimated date of change to the new behavior: 2023-06-01.\n`);
292
314
 
293
315
  settings.trackSync('Job Render Failed', { job_id: job.uid, error: 'aerender_output_not_found' });
294
316
  clearTimeout(timeoutID);
317
+ clearInterval(updateTimeoutInterval);
295
318
  return reject(new Error(`Couldn't find a result file: ${outputFile}`))
296
319
  }
297
320
 
@@ -310,6 +333,7 @@ Estimated date of change to the new behavior: 2023-06-01.\n`);
310
333
  });
311
334
 
312
335
  clearTimeout(timeoutID);
336
+ clearInterval(updateTimeoutInterval);
313
337
  resolve(job)
314
338
  });
315
339