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)
Here's a link to a minimum reproduction
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.
I wish I knew. Kafka is still pretty strange to me :sweat_smile:
â–¶ 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
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
I was wondering if that might be the case. I'll report with the kafkajs repo
@jmcdo29 - did you ever find the solution to this?
@willsoto no, I didn't. I never got around to reporting to kafka.js either unfortunately.
I found this one that was filed around the same time, but no one seems to have a solution.
@jmcdo29 @kamilmysliwiec - Fixed via #5422. This was indeed a bug in Nest
Any idea when the fix will be released? I'm monkey patching this on @nestjs/microservices 7.5.5 for now, but this is not satisfaying
Most helpful comment
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