You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was debugging an error in js-libp2p which caused it to be unable to connect to peers in a production build in browser build by webpack using create-react-app framework.
I finally found this error message in the logs when a connection fails: TypeError: Failed to construct 'AbortController': Please use the 'new' operator, this DOM object constructor cannot be called as a function.
The problem is the super() call in the constructor of TimeoutController here: master/index.js#L10.
If I replace the implementation of TimeoutController with one that uses JS prototypes rather than JS classes I get no errors and the connections happen as intended. Not sure if it actually works anymore like that tho'.
I do not know why this happens only in a production build and not in a development setup (webpack-dev-server) but this does happen consistently and prevents libp2p connections in create-react-app based apps.
The text was updated successfully, but these errors were encountered:
@latenssi what is your es build target for webpack? I am wondering if the production build is compiling to es5 resulting in a _super.call(this) type of call, which might cause this error. The dev server is likely just using es6 targets.
I was debugging an error in js-libp2p which caused it to be unable to connect to peers in a production build in browser build by webpack using create-react-app framework.
I finally found this error message in the logs when a connection fails:
TypeError: Failed to construct 'AbortController': Please use the 'new' operator, this DOM object constructor cannot be called as a function.
The problem is the
super()
call in the constructor of TimeoutController here: master/index.js#L10.If I replace the implementation of TimeoutController with one that uses JS prototypes rather than JS classes I get no errors and the connections happen as intended. Not sure if it actually works anymore like that tho'.
I do not know why this happens only in a production build and not in a development setup (webpack-dev-server) but this does happen consistently and prevents libp2p connections in create-react-app based apps.
The text was updated successfully, but these errors were encountered: