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

Command's middleware not reset between API calls #1935

Closed
AllanZhengYP opened this issue Jan 20, 2021 · 1 comment · Fixed by #1964
Closed

Command's middleware not reset between API calls #1935

AllanZhengYP opened this issue Jan 20, 2021 · 1 comment · Fixed by #1964
Labels
bug This issue is a bug. needs-triage This issue or PR still needs to be triaged.

Comments

@AllanZhengYP
Copy link
Contributor

Describe the bug
After #1883, the Command's middleware won't be added to the stack repeatedly when calling resolveMiddleware(). However, it introduces another bug: If a command instance is used by a different client instance, the command still consumes the configuration of the previous client interface.

For example

resolveMiddleware(
clientStack: MiddlewareStack<ServiceInputTypes, ServiceOutputTypes>,
configuration: AccessAnalyzerClientResolvedConfig,
options?: __HttpHandlerOptions
): Handler<CreateAnalyzerCommandInput, CreateAnalyzerCommandOutput> {
if (!this.resolved) {
this.middlewareStack.use(getSerdePlugin(configuration, this.serialize, this.deserialize));
this.resolved = true;
}

The getSerdePlugin() consumes the configuration from the client AccessAnalyzerClientResolvedConfig. if a new client with a different configuration send this command, the configuration consumed by getSerdePlugin won't be updated.

SDK version number
v3.3.0

Is the issue in the browser/Node.js/ReactNative?
Browser & Node.js & ReactNative

To Reproduce (observed behavior)

Here's the code snippet:

const command = new CreateAnalyzerCommand(params);
const client1 = new AccessAnalyzerClient(options);
// Sent to endpoint access-analyzer.us-west-2.amazonaws.com
await client1.send(command);
const client2 = new AccessAnalyzerClient({ ...options, endpoint: "https://foo.some-endpoints.com" });
// Still sent to access-analyzer.us-west-2.amazonaws.com
await client2.send(command);

Expected behavior
The configuration should be updated between the invocations.

Additional context
The key to solving this problem is to re-add the native command's middleware every time in resolveMiddleare(), without re-introducing the bug #1864. A solution would be introducing an internal MiddlewareStack API that allows native middleware to be added to the stack repeatedly, without duplicated middleware name exceptions. This should be low-risk because only the middleware shipped with SDK natively will need to do so.

@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug This issue is a bug. needs-triage This issue or PR still needs to be triaged.
Projects
None yet
1 participant