MaxListenersExceededWarning when previewFeatures = ["nApi"] added to schema.
See original GitHub issueBug description
Hello,
When I enable the previewFeatures = [“nApi”] feature I receive a few (like 5 or 6) of the following errors:
(node:29427) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 beforeExit listeners added to [process]. Use emitter.setMaxListeners() to increase limit
(Use `node --trace-warnings ...` to show where the warning was created)
(node:29427) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 exit listeners added to [process]. Use emitter.setMaxListeners() to increase limit
(node:29427) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 SIGINT listeners added to [process]. Use emitter.setMaxListeners() to increase limit
(node:29427) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 SIGUSR1 listeners added to [process]. Use emitter.setMaxListeners() to increase limit
(node:29427) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 SIGUSR2 listeners added to [process]. Use emitter.setMaxListeners() to increase limit
(node:29427) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 SIGTERM listeners added to [process]. Use emitter.setMaxListeners() to increase limit
The error is not present when I disable nApi.
I am running a NX mono repo with NestJS.
[System Information] OS Version : Linux 5.4 NodeJS Version : v14.15.3 YARN Version : 1.22.10 Nest CLI Version : 7.6.0
I have a nx nestjs lib called data-access module like below:
data-access.module.ts
import { Module } from '@nestjs/common'
import { Data_Access__Service } from './data-access.service'
@Module({
providers: [Data_Access__Service],
})
export class Data_Access__Module {}
data-access.service
import { INestApplication, Injectable, OnModuleInit } from '@nestjs/common'
import { PrismaClient } from './@prisma'
@Injectable()
export class Data_Access__Service extends PrismaClient implements OnModuleInit {
async onModuleInit() {
await this.$connect()
}
async enableShutdownHooks(app: INestApplication) {
this.$on('beforeExit', async () => {
await app.close()
})
}
}
From there, I import the Data_Access_Service into another lib module and in service put it in the constructor like:
constructor(
private readonly db: Data_Access__Service,
) {}
Then I can access the prisma client in the service. Its a little bit complex, let me know if you want any more info or even screen share somehow.
How to reproduce
Expected behavior
No response
Prisma information
Environment & setup
- OS:
- Database:
- Node.js version:
Prisma Version
prisma : 2.26.0
@prisma/client : 2.26.0
Current platform : debian-openssl-1.1.x
Query Engine : query-engine 9b816b3aa13cc270074f172f30d6eda8a8ce867d (at node_modules/prisma/node_modules/@prisma/engines/query-engine-debian-openssl-1.1.x)
Migration Engine : migration-engine-cli 9b816b3aa13cc270074f172f30d6eda8a8ce867d (at node_modules/prisma/node_modules/@prisma/engines/migration-engine-debian-openssl-1.1.x)
Introspection Engine : introspection-core 9b816b3aa13cc270074f172f30d6eda8a8ce867d (at node_modules/prisma/node_modules/@prisma/engines/introspection-engine-debian-openssl-1.1.x)
Format Binary : prisma-fmt 9b816b3aa13cc270074f172f30d6eda8a8ce867d (at node_modules/prisma/node_modules/@prisma/engines/prisma-fmt-debian-openssl-1.1.x)
Default Engines Hash : 9b816b3aa13cc270074f172f30d6eda8a8ce867d
Studio : 0.408.0
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (6 by maintainers)
Top Results From Across the Web
Possible EventEmitter memory leak detected" when ... - GitHub
"MaxListenersExceededWarning: Possible EventEmitter memory leak detected" when creating models with autoCreate: true before mongoose.connect() #9778.
Read more >Possible EventEmitter memory leak detected. 11 message lis ...
(node:5716) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 message lis teners added. Use emitter.setMaxListeners() ...
Read more >[NODE-2123] MaxListenersExceededWarning caused by ...
I am currently running a three member replica set (primary, secondary and arbiter). When I stop my primary using `service mongod stop`, ...
Read more >mongoose aggregation Code Example - Code Grepper
Add a Grepper Answer ... mongoose schema aggregation lookup multiple collections ... cannot find module bcrypt/lib/binding/napi-v3/bcrypt_lib.node ...
Read more >Actions execution throws "MaxListenersExceededWarning"
This error is a warning that is related to some of the necessary wrapping business logic for Actions and should not have any...
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 FreeTop 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
Top GitHub Comments
Relevant StackOverflow: https://stackoverflow.com/questions/50709059/maxlistenersexceededwarning-possible-eventemitter-memory-leak-detected-11-mess
I’m pretty busy at the moment with my primary job, sorry. You can recreate this issue by fetching the data I’m using and try to
createMany
with it.