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.
Fixes -> https://codesandbox.io/s/purple-star-n3ohc?file=/src/index.js
This scopes the request object to an individual request. This allows for calling a wrapped handler multiple times concurrently. This is useful when trying to reuse individual handlers when batching. Without this a handler may receive the wrong request or return the incorrect response when calling concurrently.
Does this close any currently open issues?
middyjs#558
Any other comments?
This could be considered a breaking change if someone was mutating the handler object intending it to persist between requests.
That being said there would be no reason to store your global state on the handler itself unless you thought it was scoped per request which this implements.
Where has this been tested?
Node.js Versions: 10/12
Middy Versions: 1.2.0
AWS SDK Versions: 2.713.0
Todo list
[x] Feature/Fix fully implemented
[ ] Added tests
[ ] Updated relevant documentation
[ ] Updated relevant examples