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

WebTorrent not support for Buffer on browser #671

Closed
jimliang opened this issue Mar 13, 2016 · 4 comments
Closed

WebTorrent not support for Buffer on browser #671

jimliang opened this issue Mar 13, 2016 · 4 comments

Comments

@jimliang
Copy link

@jimliang jimliang commented Mar 13, 2016

  • WebTorrent version: 0.85.1
  • Node.js version: v4.2.2
  • Browser name/version (if using WebTorrent in the browser): Chrome/49.0.2623.87

using webpack as a bundler.
Because it do not support require('webtorrent') with webpack(see #347 ),i use require('webtorrent/webtorrent.min') in the browser.
But it return undefined when webtorrent.get(new Buffer(...)).
It seen that webtorrent.min cannot parse a Buffer Object.

@Autarc

This comment has been minimized.

Copy link
Contributor

@Autarc Autarc commented Mar 16, 2016

The problem is that create-torrent currently expects buffers and streams to have a name. While its not common you can just attach the name property to the buffer object. Perhaps in an upcoming version this will be obsolete.

Aside of using the static webtorrent.min built you can checkout the configurations which have to be set to enable the webtorrent package to work in webpack.

@feross

This comment has been minimized.

Copy link
Member

@feross feross commented Mar 16, 2016

@Autarc The create-torrent issue seems unrelated. @jimliang is discussing the client.get function, which is used to look up an existing torrent.

@jimliang Please share a complete code example. It sounds like you're using the wrong function. client.add allows you to download a new torrent, not client.get.

@jimliang

This comment has been minimized.

Copy link
Author

@jimliang jimliang commented Mar 18, 2016

html:

<script src="webtorrent.min.js"></script>
<script src="bundle.js"></script>

bundle.js is created by webpack.Source:

const client = new WebTorrent();
client.add(new Buffer(...),(torrent)=>{});

Throwing Invalid torrent identifier(…) on the browser.

Now I use browserify instead of webpack.This issue can close. :3

@feross feross closed this Mar 19, 2016
@Yhozen

This comment has been minimized.

Copy link

@Yhozen Yhozen commented Jan 31, 2018

@Autarc I would like to see those configurations but the link is dead

@lock lock bot locked as resolved and limited conversation to collaborators May 25, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.