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.

dynamic Modules metadata does not support circular structures

See original GitHub issue

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


Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
BrunnerLiviocommented, 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.

2reactions
kamilmysliwieccommented, May 25, 2018

Fixed in v5.0.1

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to deal with NestJS circular dependency when using ...
I'm trying to make a NestJS Library for an API I want to access. I split it off into its own library where...
Read more >
ModuleMetadata | Android Open Source Project
The ModuleMetadata module contains metadata about the list of modules on a given device. The metadata is parsed and cached as soon as...
Read more >
AOT metadata errors - Angular
The following are metadata errors you may encounter, with explanations and suggested corrections. Expression form not supported
Read more >
Modules | NestJS - A progressive Node.js framework
A module is a class annotated with a @Module() decorator. The @Module() decorator provides metadata that Nest makes use of to organize the...
Read more >
Python import: Advanced Techniques and Tips
If math is defined as a submodule within a package, then it won't shadow the built-in module. Remove ads. Example: Structure Your Imports....
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