Open camilleanne opened 9 years ago
Yeah if we can confirm that the issue goes away when aws-sdk is not included in the bundle, then we should patch the bundling function to explicitly exclude aws-sdk from the bundle.
Its a little confusing -- I've seen this work fine in libs that don't explicitly depend on aws-sdk but one of its dependencies does, so the bundle probably does include aws-sdk though not at the top level. I'll work on seeing if I can make a little test to isolate these cases.
I wasn't able to reproduce the problem -- I modified the streambot-example to bundle aws-sdk 2.1.25 and with the following streambot module code:
var AWS = require('aws-sdk');
var streambot = require('streambot');
module.exports.streambot = streambot(exampleService);
function exampleService(records, callback) {
var kms = new AWS.KMS();
kms.listAliases({}, function(err, data) {
if (err) streambot.log.error(err);
else streambot.log.info(data);
callback();
});
}
by updating npm @2.1.6
to npm @2.9.0
I was able to get around this issue. I diffed the bundle created on 2.1.6
vs the one created with 2.9.0
: https://gist.github.com/camilleanne/b95e9dd24427497e6ef7
It still remains a mystery why this made a difference since the diffs don't look particularly telling.
I hit an odd bug when setting up a streambot lib that requires the aws-sdk for kms, but if
aws-sdk
is declared in thepackage.json
I get aCannot find module 'xmlbuilder'
error bubbling up from theaws-sdk
. This occurs even after investigating thebundle.zip
and finding thataws-sdk
with thexmlbuilder
module is installed correctly.If
aws-sdk
is removed frompackage.json
,aws-sdk
still is installed into the node_modules folder inbundle.zip
because of https://github.com/mapbox/streambot/blob/master/bin/bundle#L24. I still see an error in the lambda logs, but it's changed to something likecannot find index
(actual log has been lost. Seems that when you change the event source it clears the logs -- logs are stored by shardId and it looks like previous logs were overwritten).If I make sure that there is no
aws-sdk
installed inbundle.zip
, everything works fine.Maybe this has something to do with:
and bad interactions between versions? Perhaps this case only occurs when deploying a lambda function that requires
aws-sdk
directly.cc @mick @rclark