nestjs / nest

A progressive Node.js framework for building efficient, scalable, and enterprise-grade server-side applications with TypeScript/JavaScript 🚀
https://nestjs.com
MIT License
66.91k stars 7.55k forks source link

Calling app.close() for an app with multiple datasources throws an error #10870

Closed DenisaHalmaghi closed 1 year ago

DenisaHalmaghi commented 1 year ago

Is there an existing issue for this?

Current behavior

The app throws an error when it is closed:

UnknownElementException [Error]: Nest could not find DataSource element (this provider does not exist in the current context)
    at InstanceLinksHost.get ([path]/node_modules/@nestjs/core/injector/instance-links-host.js:24:19)
    at ModuleRef.find ([path]/node_modules/@nestjs/core/injector/abstract-instance-resolver.js:8:60)
    at ModuleRef.get ([path]/node_modules/@nestjs/core/injector/module.js:349:28)
    at TypeOrmCoreModule.<anonymous> ([path]/node_modules/@nestjs/typeorm/dist/typeorm-core.module.js:117:47)
    at Generator.next (<anonymous>)
    at [path]/node_modules/@nestjs/typeorm/dist/typeorm-core.module.js:20:71
    at new Promise (<anonymous>)
    at __awaiter ([path]/node_modules/@nestjs/typeorm/dist/typeorm-core.module.js:16:12)
    at TypeOrmCoreModule.onApplicationShutdown ([path]/node_modules/@nestjs/typeorm/dist/typeorm-core.module.js:116:16)
    at callAppShutdownHook ([path]/node_modules/@nestjs/core/hooks/on-app-shutdown.hook.js:51:35)

### Minimum reproduction code

https://stackblitz.com/edit/nestjs-typescript-starter-urnjwu?file=src/main.ts

### Steps to reproduce

1. npm install
2. npm run start:dev

### Expected behavior

The app to be closed successfully

### Package

- [ ] I don't know. Or some 3rd-party package
- [ ] <code>@nestjs/common</code>
- [X] <code>@nestjs/core</code>
- [ ] <code>@nestjs/microservices</code>
- [ ] <code>@nestjs/platform-express</code>
- [ ] <code>@nestjs/platform-fastify</code>
- [ ] <code>@nestjs/platform-socket.io</code>
- [ ] <code>@nestjs/platform-ws</code>
- [ ] <code>@nestjs/testing</code>
- [ ] <code>@nestjs/websockets</code>
- [ ] Other (see below)

### Other package

_No response_

### NestJS version

9.2.1

### Packages versions

[Nest CLI] Nest CLI Version : 9.1.8

[Nest Platform Information] platform-express version : 9.2.1 schematics version : 9.0.4 typeorm version : 9.0.1 testing version : 9.2.1 common version : 9.2.1 config version : 2.2.0 core version : 9.2.1 cli version : 9.1.8



### Node.js version

18.12.1

### In which operating systems have you tested?

- [ ] macOS
- [ ] Windows
- [ ] Linux

### Other

_No response_
Tony133 commented 1 year ago

Hi @DenisaHalmaghi, for this type of question try to use the support discord channel

The NestJS Core team uses GitHub to track bug reports, feature requests, and regressions.

kamilmysliwiec commented 1 year ago

Please, use our Discord channel (support) for such questions. We are using GitHub to track bugs, feature requests, and potential improvements.