TypeError: Cannot read property 'filter' of undefined
javorosas opened this issue · comments
My deploy is failing on the deploy:publish
stage throwing the following stack trace:
'deploy:publish' errored after 890 ms
TypeError: Cannot read property 'filter' of undefined
at /my_home_path/dev/my_project/node_modules/shipit-deploy/tasks/deploy/publish.js:40:44
at tryCatcher (/my_home_path/.nvm/versions/node/v6.9.2/lib/node_modules/shipit-cli/node_modules/ssh-pool/node_modules/bluebird/js/main/util.js:26:23)
at Promise._settlePromiseFromHandler (/my_home_path/.nvm/versions/node/v6.9.2/lib/node_modules/shipit-cli/node_modules/ssh-pool/node_modules/bluebird/js/main/promise.js:510:31)
at Promise._settlePromiseAt (/my_home_path/.nvm/versions/node/v6.9.2/lib/node_modules/shipit-cli/node_modules/ssh-pool/node_modules/bluebird/js/main/promise.js:584:18)
at Promise._settlePromises (/my_home_path/.nvm/versions/node/v6.9.2/lib/node_modules/shipit-cli/node_modules/ssh-pool/node_modules/bluebird/js/main/promise.js:700:14)
at Async._drainQueue (/my_home_path/.nvm/versions/node/v6.9.2/lib/node_modules/shipit-cli/node_modules/ssh-pool/node_modules/bluebird/js/main/async.js:123:16)
at Async._drainQueues (/my_home_path/.nvm/versions/node/v6.9.2/lib/node_modules/shipit-cli/node_modules/ssh-pool/node_modules/bluebird/js/main/async.js:133:10)
at Immediate.Async.drainQueues (/my_home_path/.nvm/versions/node/v6.9.2/lib/node_modules/shipit-cli/node_modules/ssh-pool/node_modules/bluebird/js/main/async.js:15:14)
at runCallback (timers.js:637:20)
at tryOnImmediate (timers.js:610:5)
at processImmediate [as _immediateCallback] (timers.js:582:5)
I went to publish.js:40:44
and console.log
-ed the resp
parameter. Run the thing again and this is the output:
[ { child:
ChildProcess {
domain: null,
_events: [Object],
_eventsCount: 2,
_maxListeners: undefined,
_closesNeeded: 3,
_closesGot: 3,
connected: false,
signalCode: null,
exitCode: 0,
killed: false,
spawnfile: '/bin/sh',
_handle: null,
spawnargs: [Object],
pid: 26423,
stdin: [Object],
stdout: [Object],
stderr: [Object],
stdio: [Object] },
stdout: '',
stderr: '' } ]
So apparently resp.stdout
is expected to be an array, but it's actually an empty string. I wonder if this is an unhandled case issue from shipit-deploy or shipit should actually return an array for stdout on the shipit.remote()
method.
I've seen the same error appear since the 2.5.0 release.
It's a temporary solution for me:
edit ./node_modules/shipit-deploy/tasks/deploy/publish.js line 40
...
// Fix `shipit-deploy` issue
// https://github.com/shipitjs/shipit-deploy/issues/142
try {
var failedresult = res ? res.stdout.filter(function(r) {
return r.indexOf('could not make symlink') > -1;
}) : [];
} catch (err) {
console.error(err);
var failedresult = [];
}
...
I did this instead as a temporary solution:
edit ./node_modules/shipit-deploy/tasks/deploy/publish.js line 40
...
var failedresult = (res && res.stdout) ? res.stdout.filter(function(r) {
...
But sometimes, res.stdout = ""
and res.stdout.filter
will throw an error!
@l19861225q
empty strings are falsy in JavaScript
console.log(!""); // true
You're right, I forgot it ~
Just encountered this, think this is related to this thread: shipitjs/shipit#18
PR #143 implementing @javorosas fix
Thanks for the fix and PR @javorosas @4t4r1.
Published in 2.5.1