Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dynamic Modules metadata does not support circular structures #678

Closed
cdiaz opened this issue May 14, 2018 · 7 comments
Closed

dynamic Modules metadata does not support circular structures #678

cdiaz opened this issue May 14, 2018 · 7 comments

Comments

@cdiaz
Copy link

cdiaz commented May 14, 2018

I'm submitting a...


[ ] Regression 
[X] Bug report
[ ] Feature request
[ ] Documentation issue or request

Current behavior

[Nest] 2998   - 2018-5-13 19:41:01   [ExceptionHandler] Converting circular structure to JSON
TypeError: Converting circular structure to JSON
    at JSON.stringify (<anonymous>)
    at ModuleTokenFactory.getDynamicMetadataToken (/home/nest/uroboros/node_modules/@nestjs/core/injector/module-token-factory.js:16:45)
    at ModuleTokenFactory.create (/home/nest/uroboros/node_modules/@nestjs/core/injector/module-token-factory.js:10:27)
    at ModuleCompiler.compile (/home/nest/uroboros/node_modules/@nestjs/core/injector/compiler.js:19:47)
    at NestContainer.addModule (/home/nest/uroboros/node_modules/@nestjs/core/injector/container.js:31:70)
    at DependenciesScanner.storeModule (/home/nest/uroboros/node_modules/@nestjs/core/scanner.js:32:24)
    at DependenciesScanner.scanForModules (/home/nest/uroboros/node_modules/@nestjs/core/scanner.js:22:14)
    at modules.map.innerModule (/home/nest/uroboros/node_modules/@nestjs/core/scanner.js:25:18)
    at Array.map (<anonymous>)
    at DependenciesScanner.scanForModules (/home/nest/uroboros/node_modules/@nestjs/core/scanner.js:24:17)

Expected behavior

Nest application successfully started

Minimal reproduction of the problem with instructions

import { DynamicModule, Module } from '@nestjs/common';

@Module({})
export class UroburosModule {

  static forRoot(): DynamicModule {
    let oyra = {bora:{}};
    const UroburosProvider = {
      name: 'UROBUROS_PROVIDER',
      provide: 'UROBUROS_PROVIDER',
      useValue: oyra.bora = oyra
    };

    return {
      module: UroburosModule,
      providers: [UroburosProvider],
      exports: [UroburosProvider]
    };
  }

}

What is the motivation / use case for changing the behavior?

Allow use of external libraries that contain circular references

Environment


Nest version: 5.0.0

 
For Tooling issues:
- Node version: 10.0.0
- Platform:  Linux

@cdiaz cdiaz changed the title dynamic Modules does not support circular structures as metadata dynamic Modules metadata does not support circular structures May 14, 2018
@kamilmysliwiec
Copy link
Member

Thanks @cdiaz, I'm on it

@kamilmysliwiec
Copy link
Member

Fixed in v5.0.1

@BrunnerLivio
Copy link
Member

BrunnerLivio commented Oct 1, 2018

Currently trying to upgrade my Nest 4.x.x application to 5.3.10.

My application does have a circular dynamic module and works perfectly fine with 4.x.x, but I'm having the error message TypeError: Converting circular structure to JSON

Looking through your commit history, the commit which fixed this issue is more or less reverted by commit ce498e86150f7de4a260f0c393d47ec4cc920ea1.

Why is this? Can not find any statement on this.

@cdiaz
Copy link
Author

cdiaz commented Oct 4, 2018

@kamilmysliwiec Please, reopen this issue, Apparently this commit in which changes are reverted, has reopened the problem

@kamilmysliwiec
Copy link
Member

Solved by #1142, I'll merge it soon

@kamilmysliwiec
Copy link
Member

Published as 5.3.11

@lock
Copy link

lock bot commented Sep 24, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Sep 24, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants