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

fix!: remove CustomEvent export from @libp2p/interface #2656

Merged
merged 1 commit into from
Aug 14, 2024

Conversation

achingbrain
Copy link
Member

CustomEvent is global in Node.js as of v18.7.0. We support LTS and Current which means v20+, and Electron has upgraded to node 20 so the polyfill isn't necessary any more.

BREAKING CHANGE: @libp2p/interface no longer exports a CustomEvent polyfill

Change checklist

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation if necessary (this includes comments as well)
  • I have added tests that prove my fix is effective or that my feature works

`CustomEvent` is global in Node.js as of `v18.7.0`. We support LTS
and Current which means `v20+`, and Electron has upgraded to node
20 so the polyfill isn't necessary any more.

BREAKING CHANGE: `@libp2p/interface` no longer exports a `CustomEvent` polyfill
@achingbrain achingbrain requested a review from a team as a code owner August 9, 2024 14:41
@achingbrain achingbrain mentioned this pull request Aug 9, 2024
27 tasks
@achingbrain achingbrain changed the base branch from main to release-v2.0 August 9, 2024 14:42
@achingbrain achingbrain added the version-2.0 PRs that will be released in libp2p v2 label Aug 9, 2024
@maschad
Copy link
Member

maschad commented Aug 10, 2024

@achingbrain Should we temporarily disable the interop tests in this PR and then re-enable once gossipsub upgrades it's @libp2p/interface version?

@achingbrain
Copy link
Member Author

@maschad it shouldn't be necessary - when ChainSafe/js-libp2p-gossipsub#500 is merged gossipsub will use the global CustomEvent and the tests should pass.

@achingbrain achingbrain merged commit a39bddc into release-v2.0 Aug 14, 2024
25 checks passed
@achingbrain achingbrain deleted the fix/remove-customevent-export branch August 14, 2024 12:44
xendarboh added a commit to 0KnowledgeNetwork/appchain-agent that referenced this pull request Aug 26, 2024
We're on nodejs v18 until o1js/protokit upgrades.

@libp2p says: "We support LTS and Current which means v20+"

Related:
- libp2p/js-libp2p#2656
- libp2p/js-libp2p#2652

Fixes error:
TypeError: CustomEvent is not a constructor
    at TypedEventEmitter.safeDispatchEvent
(file:///.../appchain-agent/node_modules/.pnpm/@libp2p+interface@1.7.0/node_modules/@libp2p/interface/dist/src/event-target.js:53:35)
@marcus-pousette
Copy link
Contributor

I am using NodeJS 18.20.4 and get

"CustomEvent is not a constructor"

error. But works with NodeJS 20. Have some version of 18 been verified to work?

@leblowl
Copy link

leblowl commented Aug 29, 2024

@marcus-pousette --experimental-global-customevent seems to work for me, but when I import 'node:events' I don't see it on 18.15.0

achingbrain added a commit that referenced this pull request Sep 6, 2024
`CustomEvent` is global in Node.js as of `v18.7.0`. We support LTS
and Current which means `v20+`, and Electron has upgraded to node
20 so the polyfill isn't necessary any more.

BREAKING CHANGE: `@libp2p/interface` no longer exports a `CustomEvent` polyfill
achingbrain added a commit that referenced this pull request Sep 6, 2024
`CustomEvent` is global in Node.js as of `v18.7.0`. We support LTS
and Current which means `v20+`, and Electron has upgraded to node
20 so the polyfill isn't necessary any more.

BREAKING CHANGE: `@libp2p/interface` no longer exports a `CustomEvent` polyfill
@achingbrain achingbrain mentioned this pull request Sep 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
version-2.0 PRs that will be released in libp2p v2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants