Circular dependency with noop.js
See original GitHub issueThe circular dependency of Tracer -> noop -> Tracer is definitely a code smell that is worked around here with an initialize
function that needs to be called. Why not simply remove the noop.js file, and let the tracer, span etc files export a noop instance (if we need an eagerly instantiated instance at all)?
Issue Analytics
- State:
- Created 6 years ago
- Comments:8 (8 by maintainers)
Top Results From Across the Web
How to Eliminate Circular Dependencies from Your JavaScript ...
In my experience, the best way to deal with circular dependencies is to avoid them altogether. Circular dependencies are usually an indication ...
Read more >Resolving circular dependencies with Node.js require and ...
This is a bit of a hack, but seems to be one common way of resolving circular dependencies by moving the module.exports before...
Read more >Circular Dependency in Node.js modules! - LinkedIn
A circular dependency between Node.js modules occurs when the modules require() each other. This dependency results in an incomplete module ...
Read more >The Curious Case of Circular Dependencies in Node - Medium
If we closely look at document-service.js and registration-service.js , they're both referencing each other causing a circular dependency ...
Read more >Identifying Circular Dependencies in JavaScript Modules
While recently scouring Stack Overflow to debug a vague error in a JavaScript library I was working on, one of the possible causes...
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
Good point. Could be a remnant of the original design that required the use of delegate, which was later change to define just an API that can be implemented independently.
I think the dependency should be
Currently there are no interfaces to implement, the
Tracer
,Span
etc classes actually already act as a noop implementation. I use successfully like that: https://sourcegraph.com/github.com/sourcegraph/javascript-typescript-langserver/-/blob/src/project-manager.ts#L834-835 I allow to pass a parent span, and default it to a noop span if none is passed.