TritonDataCenter / node-workflow

Task orchestration, creation and running using NodeJS
MIT License
456 stars 66 forks source link

error when referencing same task in multiple chains of a workflow #153

Closed TomKaltz closed 8 years ago

TomKaltz commented 8 years ago

I am trying to do...

var checkCanWrite = require('../tasks/checkCanWrite')
var checkExists = require('../tasks/checkExists')
var transcodeFile = require('../tasks/transcodeFile')
var killPid = require('../tasks/killPid')

module.exports = {
    name: 'video transcode',
    chain: [checkExists,checkCanWrite,transcodeFile],
    timeout: 7200,
    onError: [killPid],
    onCancel: [killPid]
}

When I try to insert this workflow into the database using factory.workflow() I get the error Task "body" must be a function.

I am using killPid task for both onError and onCancel. If I remove the onCancel line from my workflow, no error occurs.

TomKaltz commented 8 years ago

I have worked around this by cloning the required task like...

var checkCanWrite = require('../tasks/checkCanWrite')
var checkExists = require('../tasks/checkExists')
var transcodeFile = require('../tasks/transcodeFile')
var killPid = require('../tasks/killPid')
var killPid2 = Object.assign({},killPid)

module.exports = {
    name: 'video transcode',
    chain: [checkExists,checkCanWrite,transcodeFile],
    timeout: 7200,
    onError: [killPid],
    onCancel: [killPid2]
}