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

Checking for WebSockets constructor name fails under uglification #65

Closed
jackkleeman opened this issue Mar 26, 2017 · 8 comments
Closed
Assignees
Labels
exp/expert Having worked on the specific codebase is important exploration help wanted Seeking public contribution on this issue kind/bug A bug in existing code (including security flaws)

Comments

@jackkleeman
Copy link
Contributor

Currently to add the WebSockets transport index.js does a check for the constructor.name being 'WebSockets'. This fails under uglification unless 'WebSockets' is made a reserved word in the uglify config, as constructor names are one of the things uglify removes. I recommend that either this is documented, or a different solution is devised; there is already a TODO in the code suggesting that this is found. For example, we could standardise some kind of boolean flag in a transport class which tells libp2p to include it even if there are no listening addresses. That wouldn't be websocket-specific, and wouldn't require checking the name against a string.

@dignifiedquire
Copy link
Member

This is unfortunate, we use this pattern in a couple of places. I guess we need to find a new way to do these kinds of detections.

@dignifiedquire dignifiedquire added kind/bug A bug in existing code (including security flaws) help wanted Seeking public contribution on this issue exploration labels Mar 26, 2017
@daviddias
Copy link
Member

Trying to come up with an elegant solution and I always end up in making something that looks too complicated. The crux of this problem is the fact that we might handle several versions of the same module that are compatible with each other, but because of the dependency tree, they coexist.

Seems that we need to go 🦆 typing all the way, which isn't the best, but will suffice for the majority (if not all) the cases.

@daviddias daviddias added exp/expert Having worked on the specific codebase is important status/deferred Conscious decision to pause or backlog labels Jul 9, 2017
@mqzry
Copy link

mqzry commented Aug 9, 2017

Warning: I did not look at the code yet.
Can't you just specify a regex to the mangle-regex option of uglify that matches functions starting with a capital? Not the most robust solution though.

Can you explain the crux of the problem a bit more? I might try to solve this issue

@dryajov
Copy link
Member

dryajov commented Aug 9, 2017

Actually libp2p (as well as libp2p-swarm) uses the .tag property as the primary way to determine the name of the transport, it uses .constructor.name only as a fallback, so it should be possible to just set the .tag as the name of the transport. I like this solution and I explicitly set .tag to Circtuit in libp2p-circuit, for example.

@daviddias
Copy link
Member

@fsdiogo is handling this.

@fsdiogo
Copy link
Member

fsdiogo commented Apr 3, 2018

PR #182 fixes this.

@fsdiogo
Copy link
Member

fsdiogo commented Apr 23, 2018

Check ipfs/js-ipfs#1321 for more info.

@fsdiogo fsdiogo closed this as completed Apr 23, 2018
@ghost ghost removed the status/deferred Conscious decision to pause or backlog label Apr 23, 2018
@daviddias
Copy link
Member

WoooT!

maschad pushed a commit to maschad/js-libp2p that referenced this issue Jun 21, 2023
maschad pushed a commit to maschad/js-libp2p that referenced this issue Jun 21, 2023
maschad pushed a commit to maschad/js-libp2p that referenced this issue Jun 21, 2023
Updates project config using the `aegir check-project` command.

* Updates CI files ahead of turning on unified CI
* Resets project version to 0 (otherwise first version published will be 2.0.0)
* Renames project to publish under @libp2p namespace
* Standardises readme
* Remove unused dependencies
* Use chai from aegir
* Fix formatting in example
maschad pushed a commit to maschad/js-libp2p that referenced this issue Jun 21, 2023
## 1.0.0 (2022-12-13)

### Bug Fixes

* update project config ([libp2p#65](libp2p/js-libp2p-webrtc#65)) ([09c33cc](libp2p/js-libp2p-webrtc@09c33cc))

### Dependencies

* update libp2p to release version ([dbd0237](libp2p/js-libp2p-webrtc@dbd0237))

### Trivial Changes

* Update .github/workflows/stale.yml [skip ci] ([43c70bc](libp2p/js-libp2p-webrtc@43c70bc))

### Documentation

* fix 'browser to server' build config ([libp2p#66](libp2p/js-libp2p-webrtc#66)) ([b54132c](libp2p/js-libp2p-webrtc@b54132c))
maschad pushed a commit to maschad/js-libp2p that referenced this issue Jun 21, 2023
maschad pushed a commit to maschad/js-libp2p that referenced this issue Jun 21, 2023
## [6.0.1](libp2p/js-libp2p-peer-store@v6.0.0...v6.0.1) (2023-02-28)

### Trivial Changes

* replace err-code with CodeError ([libp2p#53](libp2p/js-libp2p-peer-store#53)) ([e6b87d7](libp2p/js-libp2p-peer-store@e6b87d7)), closes [js-libp2p#1269](libp2p#1269)
* Update .github/workflows/semantic-pull-request.yml [skip ci] ([1139dc4](libp2p/js-libp2p-peer-store@1139dc4))

### Documentation

* Update API link ([libp2p#65](libp2p/js-libp2p-peer-store#65)) ([1b75110](libp2p/js-libp2p-peer-store@1b75110)), closes [libp2p#64](libp2p/js-libp2p-peer-store#64)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
exp/expert Having worked on the specific codebase is important exploration help wanted Seeking public contribution on this issue kind/bug A bug in existing code (including security flaws)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants