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

Unexpected behaviour when bundled by Vite (and likely WebPack and other bundlers) #48

Open
Tomaszal opened this issue Apr 12, 2022 · 0 comments

Comments

@Tomaszal
Copy link

I'm trying to use this library inside of a Vue project with Vite, however, peer connections get instantly closed in that setup. I also had to add @esbuild-plugins/node-globals-polyfill and events packages in order to get P2PT to work in Vite at all, so perhaps it could be related to that. If I include P2PT using a <script> tag in the same setup it works without a problem.

I have created the following reproduction projects on Stackblitz:

If you open the import project in 2 separate tabs, you will see something along these lines:

_peerId e3560c413ad577eac4067144ac915ad9ac84fc82
trackerconnect wss://tracker.btorrent.xyz
peerclose a7e07222c5299d33686b64a70e95494a49f181a8

As you can see, the peerclose event is fired right after the tracker connection is established, where peerconnect is expected instead.

If you open the script project, where the only difference is the way P2PT is imported, you will see something along these lines:

_peerId 0e35820543c1491086ff837c80fc7f34aa9dec86
trackerconnect wss://tracker.btorrent.xyz
peerconnect 4bf610b001ff297abe9180a59379e30d462155da

I've also tried something similar on a WebPack project and had the same issue as with Vite, although I did not try to isolate it in a reproducible project. I suspect this issue might occur with other bundlers as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant