Skip to content

error using browser bundle on constructor.name #291

Closed
@hugomrdias

Description

@hugomrdias
  • Version:
  • Platform:
  • Subsystem:

Type: Bug

Severity: High

Description:

I found this error testing the experimental aegir build, still don't know why this happens, minified and un-minified bundles give the same error so it isn't terser (the new uglify) might be babel changing constructor name needs further investigation.
Still using constructor.name should be avoided reference below.

Reference:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/name#JavaScript_compressors_and_minifiers

Using a minified bundle this line https://github.com/libp2p/js-libp2p/blob/master/src/index.js#L362 gives an error

Uncaught Error: There is already a transport with this key
at TransportManager.add (transport.js:37)
at index.js:362
at parallel.js:31
at replenish (eachOfLimit.js:66)
at iterateeCallback (eachOfLimit.js:50)
at onlyOnce.js:12
at Switch. (parallel.js:36)
at Switch.g (events.js:165)
at Switch.EventEmitter.emit (events.js:78)
at EventEmitter. (index.js:109)

Steps to reproduce the error:

https://codesandbox.io/s/github/hugomrdias/ipfs-hd/tree/chore/test-example-codesandbox/examples/exchange-files-in-browser

in the index.html at the bottom change this line

<script src="https://unpkg.com/ipfs-hd@next"></script>

to

<script src="https://unpkg.com/ipfs-hd/dist/ipfs.js"></script> for un minified source

or

<script src="https://unpkg.com/ipfs/dist/index.js"></script> for the current ipfs bundle which works

Metadata

Metadata

Assignees

Labels

P1High: Likely tackled by core team if no one steps upexp/noviceSomeone with a little familiarity can pick uphelp wantedSeeking public contribution on this issuekind/bugA bug in existing code (including security flaws)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions