Failed to execute 'send' on 'RTCDataChannel': RTCDataChannel send queue is full
- Dominant language
- JavaScript
- Stars
- 7.8k
- Forks
- 983
- PR merge metrics
- No merged PRs in 30d
Description
**What version of this package are you using?**
9.11.1
**What operating system, Node.js, and npm version?**
node v16.15.0
npm 8.5.5
macOs 12.4
**What happened?**
I am using this package to send files.
When file size is small everything is ok.
But when I send a 240Mb file, after 28mb was received ,an `Unhandled Rejection (OperationError): Failed to execute 'send' on 'RTCDataChannel': RTCDataChannel send queue is full` error happened.
Then I change the code to
````
while (offset < filesize) {
const chunk = await readChunk(offset)
if (peer._channel.bufferedAmount >= peer._channel.bufferedAmountLowThreshold) {
peer._channel.onBufferedAmountLow = () => {
peer.send(chunk);
peer._channel.onBufferedAmountLow = null;
};
} else {
peer.send(chunk);
}
}
````
this time it just stuck forever after transfer >80Mb data.
````
while (offset < filesize) {
const chunk = await readChunk(offset)
if (peer._channel.bufferedAmount >= peer._channel.bufferedAmountLowThreshold) {
await new Promise((resolve) => {
setTimeout(() => {
peer.send(chunk);
resolve();
}, 50);
});
} else {
peer.send(chunk);
}
}
````
use promise and settimeout fix the problem ,but I have to wait and dont know 50ms is the proper duration
**What did you expect to happen?**
how to deal with `RTCDataChannel send queue is full``
**Are you willing to submit a pull request to fix this bug?**
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.