question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

MaxListenersExceededWarning when previewFeatures = ["nApi"] added to schema.

See original GitHub issue

Bug 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:closed
  • Created 2 years ago
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

0reactions
abriginetscommented, Sep 6, 2021

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found