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

fix(microservice/kafka): properly await disconnect promises #5422

Merged
merged 1 commit into from
Oct 29, 2020
Merged

fix(microservice/kafka): properly await disconnect promises #5422

merged 1 commit into from
Oct 29, 2020

Conversation

willsoto
Copy link
Contributor

@willsoto willsoto commented Sep 14, 2020

producer.disconnect() and consumer.disconnect() are promises.
Since they weren't being awaited properly, you would have Kafka code that
would attempt to execute after teardown. By waiting for the promises, those errors
go away.

Official documentation: https://kafka.js.org/docs/getting-started

Closes #4830

Here are tests from KafkaJS showing those methods as async

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

[x] Bugfix
[ ] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Other... Please describe:

What is the current behavior?

Tests with kafka do not get torn down properly

Issue Number: #4830

What is the new behavior?

Promises are handled properly and no code is executed after teardown.

Does this PR introduce a breaking change?

[ ] Yes
[x] No

Maybe? People will have to await their promises if they weren't already

Other information

Sorry, something went wrong.

@jmcdo29
Copy link
Member

jmcdo29 commented Sep 14, 2020

@coveralls
Copy link

coveralls commented Sep 14, 2020

Pull Request Test Coverage Report for Build f718f40f-aed9-43b6-b04e-4fedcc01b884

  • 2 of 2 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 94.818%

Totals Coverage Status
Change from base Build 736a64e8-08de-40ee-9990-faac31009973: 0.0%
Covered Lines: 4922
Relevant Lines: 5191

💛 - Coveralls

@willsoto
Copy link
Contributor Author

@jmcdo29 - should be good now, thank you.

@mkaufmaner
Copy link
Contributor

This LGTM! It is rather important to wait for the disconnect to occur so it ensures the brokers know that the consumer has disconnected.

Verified

This commit was signed with the committer’s verified signature.
darccio Dario Castañé
`producer.disconnect()` and `consumer.disconnect()` are promises.
Since they weren't being `await`ed properly, you would have Kafka code that
would attempt to execute after teardown. By waiting for the promises, those errors
go away.

Official documentation: https://kafka.js.org/docs/getting-started

Closes #4830
@willsoto
Copy link
Contributor Author

@jmcdo29 @kamilmysliwiec any chance this can be looked at / merged? This is a real problem when testing since connections are not properly being disconnected.

@jmcdo29
Copy link
Member

jmcdo29 commented Sep 25, 2020

Changes look good to me. I don't think it would be a problem to merge. We'll wait to hear from Kamil though 😸

@kamilmysliwiec kamilmysliwiec added this to the 7.5.0 milestone Oct 5, 2020
@kamilmysliwiec kamilmysliwiec merged commit b36ef52 into nestjs:master Oct 29, 2020
@willsoto willsoto deleted the fix/kafka-microservice branch October 29, 2020 12:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Kafka errors in E2E tests
5 participants