Prevent lambda timeouts or failure from not handled promise due to invalid SSM parameter(s)... Add throwOnFailedCall flag to the SSM middleware #572
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does this implement/fix? Explain your changes.
…
PR regarding #567
If you provide a non-existent SSM parameter to the
@middy/ssm
middleware it will cause the function to go to timeout if you are not using@middy/do-not-wait-for-empty-event-loop
, or withdo-not-wait-for-empty-event-loop
in place, it will fail immediately (the error is thrown in thehandleInvalidParams()
function but it is not handled anywhere!) and not reach the original handler!Changes:
throwOnFailedCall
flag with default valuefalse
(Same implementation as Secret Manager middleware)throwOnFailedCall=false
it will justconsole.error
the error and continue to the next middleware or main handlerthrowOnFailedCall=true
it willconsole.error
the error and throw the error thrown fromhandleInvalidParams()
p.s tested this implementation on AWS lambda with the code below... works as expected!
Does this close any currently open issues?
No
Any relevant logs, error output, etc?
(If it’s long, please paste to https://ghostbin.com/ and insert the link here.)
Any other comments?
@willfarrell let me know if something else is needed! Don't have much time to check the documentation for
do-not-wait-for-empty-event-loop
Some additional tests might be needed for the new
throwOnFailedCall
flag!Where has this been tested?
Node.js Versions: : Node v12.18.3 (npm v6.14.6)
Middy Versions: : v1.4.0
AWS SDK Versions:: ^2.771.0
Todo list
throwOnFailedCall
if needed