What version of this package are you using?
4.1.0
What operating system, Node.js, and npm version?
Linux Mint, on 6.8.0-78-generic kernel
Node 24.2.0
NPM 11.3.0
What happened?
I'm using Webtorrent as a library, but only to download/upload files, with most features disabled and a local HTTP tracker server. I can provide the Webtorrent and tracker options if needed, but I think it's not relevant.
I noticed a crash, that seems to be due to a Uint8Array (padCBuffer) being used as if it was a Buffer (which has the .copy method).
file:///..../node_modules/bittorrent-protocol/index.js:300
padCBuffer.copy(vcAndProvideBuffer, 14)
^
TypeError: padCBuffer.copy is not a function
at Wire.sendPe3 (file:///..../node_modules/bittorrent-protocol/index.js:300:16)
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
This seems to be a regression from the commit 9b77f6c , where the randombytes module was dropped. The randombytes module returned a Buffer, and the replacement returns a Uint8Array.
(Around line 271)
- const padCBuffer = randombytes(padCLen)
+ const padCBuffer = randomBytes(padCLen)
What did you expect to happen?
I would expect there not to be a crash.
Are you willing to submit a pull request to fix this bug?
Yes, but I would like to know if I'm allowed to use Buffer for it, or if I need to keep using Uint8Array for browser compatibility.
What version of this package are you using?
4.1.0
What operating system, Node.js, and npm version?
Linux Mint, on 6.8.0-78-generic kernel
Node 24.2.0
NPM 11.3.0
What happened?
I'm using Webtorrent as a library, but only to download/upload files, with most features disabled and a local HTTP tracker server. I can provide the Webtorrent and tracker options if needed, but I think it's not relevant.
I noticed a crash, that seems to be due to a Uint8Array (padCBuffer) being used as if it was a Buffer (which has the .copy method).
This seems to be a regression from the commit 9b77f6c , where the
randombytesmodule was dropped. Therandombytesmodule returned aBuffer, and the replacement returns aUint8Array.(Around line 271)
What did you expect to happen?
I would expect there not to be a crash.
Are you willing to submit a pull request to fix this bug?
Yes, but I would like to know if I'm allowed to use Buffer for it, or if I need to keep using Uint8Array for browser compatibility.