Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scope each request independently #559

Merged
merged 2 commits into from
Aug 30, 2020

Conversation

thetrevdev
Copy link
Contributor

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?

#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

Copy link
Member

@willfarrell willfarrell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lmammino Did you want to take a quick look at this one?

packages/core/index.js Outdated Show resolved Hide resolved
@willfarrell willfarrell merged commit 6745dd3 into middyjs:master Aug 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants