Skip to content
This repository has been archived by the owner on May 3, 2022. It is now read-only.

Allow multiple versions of tchannel to be require()d. #259

Open
lxe opened this issue Dec 15, 2015 · 3 comments
Open

Allow multiple versions of tchannel to be require()d. #259

lxe opened this issue Dec 15, 2015 · 3 comments

Comments

@lxe
Copy link

lxe commented Dec 15, 2015

Tchannel should't make any assumption about the module tree in which it is in. Let's assume we have the following node_modules tree:

$ npm ls tchannel
[email protected] /Users/aleksey/devel/top-level-project
├─┬ [email protected]
│ └── [email protected]
├─┬ [email protected]
│ └── [email protected]

Both dep1 and dep2 have tchannel as dependency matching all minor version up to 4:

"dependencies": {
  "tchannel": "^3.5.0"
}

Running npm install on this tree will (rightfully) mark both 3.5.0 and 3.6.0 versions as valid and matching their respective semver ranges.

I think it's a very bad practice for a module to expect a shape of the project's entire modules tree in which it is.

@Raynos
Copy link
Contributor

Raynos commented Dec 15, 2015

TChannel is a singleton. There should only be one.

We enforce this.

@lxe
Copy link
Author

lxe commented Dec 15, 2015

TChannel is a singleton. There should only be one.

We enforce this.

There are better ways:

You should warn, document, but never just throw an error. This causes unpredictable behavior across builds.

@Raynos
Copy link
Contributor

Raynos commented Dec 15, 2015

I agree there are better ways in an open source project to do this. However we have a genuine support problem that must open source projects do not have.

We've had an issue in the past where engineers created two instances of tchannel and advertised twice in the same process. This created a weird edge case in terms of load balancing behavior and they reported it as a bug.

When we said "I'm sorry; you cant create two tchannels. that's not a supported feature" they were really upset. They mentioned that we must support the library even if its used incorrectly. They mentioned that if we want to stop people from using it incorrectly we should throw.

I agree with this trade-off. We throw when TChannel is used in an unsupported fashion and we have to support all other use cases and permutations in which the library is used.

However to accommodate your need; I will add a global.TCHANNEL_UNSUPPORTED_MODE = 'I know what I am doing'; that allows you to opt out of support and use TChannel in unique unsupported ways.

This causes unpredictable behavior across builds.

As an aside shrinkwrap is the recommended way to get predictable behavior across builds ;)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants