Any workflow task that creates an instance of Error currently uses a different Error constructor than the one used by modules that are injected in the sandbox.
For instance, if a task uses the module Foo which exports the following assertIsError function:
var err = new Error('some error');
Foo.assertIsError(err);
would assert.
For a real-world use case in Triton, this caused tasks run by sdc-workflow to not be able to call the callback of a vasyncparallel/forEachParallel async workflow with an error object. Indeed, the Error instance created from the task would be passed to verror's MultiError constructor, which would in turn check if that instance is an instanceof Error. It would determine it's not, since the workflow task and the vasync (and thus verror) module would use a different Error constructor. Finally, that would make verror use extsprintf.sprintf on an object rather than a string, which would make it assert.
In that specific case, upgrading sdc-workflow's node-workflow (or wf) dependency to the tip of joyent/node-workflow#master fixes the symptom, because that version upgrades verror to a version that doesn't use instanceof Error in the same way, but the original problem is still there, and still causes some problems e.g when formatting the error message.
Any workflow task that creates an instance of
Error
currently uses a differentError
constructor than the one used by modules that are injected in the sandbox.For instance, if a task uses the module
Foo
which exports the followingassertIsError
function:then a task running the following code:
would assert.
For a real-world use case in Triton, this caused tasks run by
sdc-workflow
to not be able to call the callback of avasync
parallel
/forEachParallel
async workflow with an error object. Indeed, theError
instance created from the task would be passed toverror
'sMultiError
constructor, which would in turn check if that instance is aninstanceof Error
. It would determine it's not, since the workflow task and thevasync
(and thusverror
) module would use a differentError
constructor. Finally, that would makeverror
useextsprintf.sprintf
on an object rather than a string, which would make it assert.In that specific case, upgrading sdc-workflow's
node-workflow
(orwf
) dependency to the tip ofjoyent/node-workflow#master
fixes the symptom, because that version upgradesverror
to a version that doesn't useinstanceof Error
in the same way, but the original problem is still there, and still causes some problems e.g when formatting the error message.