assertible / lambda-cloudwatch-slack

Send AWS CloudWatch notifications to a Slack channel using Lambda
https://assertible.com/blog/npm-package-lambda-cloudwatch-slack
MIT License
482 stars 250 forks source link

TypeError: context.succeed is not a function #12

Closed quinn-influx closed 7 years ago

quinn-influx commented 7 years ago

Hello All --

I was wondering if you could help me with the error I am running into. I've used lambda-cloudwatch-slack before on another AWS account. Now I need to install it again on my new AWS account. Do you know where I am going wrong?

processing cloudwatch notification message posted successfully /home/ec2-user/lambda-cloudwatch-slack/index.js:299 context.succeed(); ^

TypeError: context.succeed is not a function at /home/ec2-user/lambda-cloudwatch-slack/index.js:299:15 at IncomingMessage. (/home/ec2-user/lambda-cloudwatch-slack/index.js:38:9) at emitNone (events.js:72:20) at IncomingMessage.emit (events.js:166:7) at endReadableNT (_stream_readable.js:913:12) at nextTickCallbackWith2Args (node.js:442:9) at process._tickDomainCallback (node.js:397:17) make: *** [test] Error 1

quinn-influx commented 7 years ago

Sorry I should be more specific...

I ran git clone https://github.com/assertible/lambda-cloudwatch-slack.git Edited the Makefile... Setup the Slack Hook... Edited the config.fs file.. Ran npm install I get that error when I run "make test"

creichert commented 7 years ago

At a glance, I'm not sure what the error is. Likely the context object is not correct due to another error.

You might try adding some debug around these statements to see if there is something obvious: https://github.com/assertible/lambda-cloudwatch-slack/search?utf8=%E2%9C%93&q=context.succeed&type=

Any PRs or updates would be appreciated if you find something.

I have been planning to give the package some love (and also merge #11) so I'll take a look at this ASAP.

CodyReichert commented 7 years ago

I think I was able to pin this one down - @quinn-influx

context.succeed and context.done are deprecated in the Node.js 4.3 and 6.10 runtimes. Thus, the node-lambda package stopped supporting them: https://github.com/motdotla/node-lambda/issues/223

Can you try this, from the package root:

$ rm -rf node_modules/node-lambda
$ npm i node-lambda@0.8.11 # Make sure you have this version
$ make test

You should see a deprecation warning in the output for context.succeed, but the tests should run. If that works for you, I'll push a PR to pin the version of node-lambda in the package.json -- or if you can that would be great.

Other than that, as @creichert said, we need to give this package a little love, and moving to the callback syntax instead of context will be a part of that.

quinn-influx commented 7 years ago

Awesome! That worked. Thank you so much for the reply!

I'll add that to my notes just in case xD

CodyReichert commented 7 years ago

@quinn-influx - thanks for confirming that.

I just merged #13 to correctly pins that package's version, and released 0.1.2 to npm..