Skip to content

Typerror when calling super() in constructor #2

Description

@latenssi

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions