Kafka errors in E2E tests
See original GitHub issueBug Report
Current behavior
In an E2E test with both the receiver and the caller as separate Nest applications started in the same test context, after closing both applications Jest reports an error about trying to import
a file after the Jest environment has been torn down.
Jest did not exit one second after the test run has completed.
This usually means that there are asynchronous operations that weren't stopped in your tests. Consider running Jest with `--detectOpenHandles` to troubleshoot this issue.
ReferenceError: You are trying to `import` a file after the Jest environment has been torn down.
at 1 (../node_modules/kafkajs/src/protocol/requests/heartbeat/index.js:11:21)
at Broker.heartbeat (../node_modules/kafkajs/src/broker/index.js:314:39)
at ConsumerGroup.heartbeat (../node_modules/kafkajs/src/consumer/consumerGroup.js:310:30)
at Runner.fetch (../node_modules/kafkajs/src/consumer/runner.js:317:30)
Input Code
Here’s a link to a minimum reproduction
Expected behavior
Be able to close out both applications with no errors? Honestly, not 100% sure if this is a bug or me implementing something incorrectly, but as the Kafka transport is experimental, I figured it should be brought up.
Possible Solution
I wish I knew. Kafka is still pretty strange to me 😅
Environment
▶ nest info
_ _ _ ___ _____ _____ _ _____
| \ | | | | |_ |/ ___|/ __ \| | |_ _|
| \| | ___ ___ | |_ | |\ `--. | / \/| | | |
| . ` | / _ \/ __|| __| | | `--. \| | | | | |
| |\ || __/\__ \| |_ /\__/ //\__/ /| \__/\| |_____| |_
\_| \_/ \___||___/ \__|\____/ \____/ \____/\_____/\___/
[System Information]
OS Version : Linux 5.0
NodeJS Version : v13.14.0
YARN Version : 1.22.4
[Nest CLI]
Nest CLI Version : 7.1.5
[Nest Platform Information]
platform-express version : 7.0.0
microservices version : 7.0.13
common version : 7.0.0
core version : 7.0.0
For Tooling issues:
- Node version: 13.14.0
- Platform: Linux Mint 19.3
Others:
Package manager: Yarn
# These two shouldn't /really/ matter, but I thought I'd add them for the full context
IDE: VSCode
Shell: ZSH
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:7 (6 by maintainers)
Top Results From Across the Web
Nestjs e2e test fails because of Kafka errors - Stack Overflow
I wrote an e2e test and when I run it (in the docker container), it fails because of Kafka connection. Here are my...
Read more >Fix testConsumeCycleWithInsufficientPrivileges test failure in ...
Test, TestConsumeCycleWithInsufficientPrivileges in TestAuthorize test class is failing. Error Message Expected message: Not authorized to access topics: ...
Read more >Advanced Testing Techniques for Spring for Apache Kafka
Testing Spring Kafka and transient errors. The following testing scenario builds off the generic processor that was built in the previous post, ...
Read more >Testing Kafka and Spring Boot - Baeldung
Learn about a couple of approaches for testing Kafka applications with Spring Boot.
Read more >A Quick and Practical Example of Kafka Testing - DZone
A developer gives a tutorial on testing Kafka applications in a declarative way and how to test Kafka- and REST-based microservices ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@jmcdo29 @kamilmysliwiec - Fixed via #5422. This was indeed a bug in Nest
After looking into this issue, I believe that it’s not related to NestJS implementation (Kafka transporter class). Perhaps we should consider reporting this issue in the kafkajs repo instead? @jmcdo29