js-libp2p icon indicating copy to clipboard operation
js-libp2p copied to clipboard

Bug in a dependency: timeout-abort-controller

Open latenssi opened this issue 5 years ago • 3 comments

  • Version: 0.27.3
  • Platform: browser (create-react-app)
  • Subsystem: timeout-abort-controller

Type: Bug

Severity: High

Description:

Bug in timeout-abort-controller package renders libp2p unusable in create-react-app build apps

I have created an issue in the repo of the package here: https://github.com/jacobheun/timeout-abort-controller/issues/2

Steps to reproduce the error:

Build a create-react-app based app (npm run build), try to connect to a peer in the app via webrtc-star and you should get this error message in the debug logs:

libp2p:error could not connect to discovered peer TypeError: Failed to construct 'AbortController': Please use the 'new' operator, this DOM object constructor cannot be called as a function.

latenssi avatar Feb 28 '20 12:02 latenssi

My create-react-app setup uses ES5 as target and as the author of the timeout-abort-controller package @jacobheun stated it will cause webpack to use a "_super.call(this) type of call" when transpiling the ES6 classes to ES5.

I am not closing this issue since others may have this same problem and I will let the maintainers of libp2p decide what to do with this issue.

I will use ES6 as target but others may not have that option

latenssi avatar Feb 28 '20 13:02 latenssi

@latenssi are you using out of the box create-react-app or are you doing any special configuration? What version of create-react-app are you using?

It looks like babel 7+ is supposed to include https://github.com/WebReflection/babel-plugin-transform-builtin-classes by default which should fix this, if not and this is out of the box create-react-app, it will probably be best to update timeout-abort-controller to support built in classes better for legacy builds out of the box to avoid this.

jacobheun avatar Feb 28 '20 14:02 jacobheun

I am using the latest version of create-react-app (out of the box) and it does not seem to include that babel plugin you mentioned, only this one: babel-plugin-transform-classes and it does not fix the problem.

I encourage anyone hitting this issue to test out the plugin @jacobheun suggested but I must move on as my situation allows me to stick to plain ES6 classes.

@jacobheun I second you in that the best way to handle the issue is to update timeout-abort-controller to support ES5 transpiling.

latenssi avatar Mar 02 '20 07:03 latenssi

timeout-abort-controller is no longer a dependency

wemeetagain avatar Sep 28 '23 02:09 wemeetagain