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.

Circular dependency with noop.js

See original GitHub issue

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

github_iconTop GitHub Comments

3reactions
yurishkurocommented, Apr 2, 2017

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

  • Tracer API
  • Noop tracer implements Trace API
  • Global tracer wrapper with a delegate of type Tracer
  • Global tracer by default initialized to Noop tracer.
0reactions
felixfbeckercommented, May 29, 2017

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.

Read more comments on GitHub >

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

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