Search code examples
javascriptnode.jsnpmgulp

How to manually setup gulp task timeout to run more than 1 hour task?


I want to run a gulp task that will last more than 1 hour (probably 6 hours or more).
At the moment, after one hour, I receive this message:

[00:32:53] 'my-long-running-task' errored after 1 h
[00:32:53] Error: Timeout
...
at module.exports (C:\myproject\node_modules\orchestrator\lib\runTask.js:34:7)
at Gulp.Orchestrator._runTask (C:\myproject\node_modules\orchestrator\index.js:273:3)
at Gulp.Orchestrator._runStep (C:\myproject\node_modules\orchestrator\index.js:214:10)
at Gulp.Orchestrator.start (C:\myproject\node_modules\orchestrator\index.js:134:8)
at C:\Users\user1\AppData\Roaming\npm\node_modules\gulp-cli\lib\versioned\^3.7.0\index.js:72:20
at _combinedTickCallback (internal/process/next_tick.js:67:7)

The task is not totally killed (the launched process continues to run) but the other steps of task are not executed.

Do you know how can I raise this one hour timeout? Or totally remove it?


Solution

  • I found the solution: In gulp I am using sync-exec and it has a maxWait parameters.

    'use strict';
    
    const gulp = require('gulp');
    const exec = require('sync-exec');    
    
    gulp.task('my-task', () => {
      let maxWaitValue = 24 * 60 * 60 * 1000;
      exec(`my task which takes very long`, maxWaitValue, config.execSyncOptions);
    });