on("error") callback function is never executed.
I'm currently using npm peerjs with webpack. When testing error handling , I found out that error (fatal and non-fatal) error would not execute the defined callback function. The console would log something like : "ERROR PeerJS : ...." and the callback code would not have been executed. I tested this both on Chrome and IE. Can anyone give me some directions?
Hey @allanbbs,
Thank you for the report. How do you provoke the error?
Can you post some logs (with {debug: 3}) and/or something to reproduce this?
Hi @jonasgloning,
It seems like I have the same problem. It seems that an 'error' event handler attached to a PeerConnection object is not triggered in case that the connection between two peers gets suddenly lost.
Sample code:
let conn = peer.connect(senderId, { reliable: true });
conn.on('open', () => {
// ...
conn.on('data', (data) => {
// ...
});
});
// ...
conn.on('close', () => {
// ...
});
conn.on('error', (err) => {
// This apparently is not executed!
});
I provoked a connection error by closing the browser window while data was being transferred between two peers. The receiver stopped receiving the data but the error event handler was not invoked.
Has this problem been fixed in the meantime or is this still an open issue?
Would be grateful for any support on this!
I found the following comment in the CHANGELOG.md file:
Connections no longer emit errors from PeerConnection; PeerConnection errors are now forwarded to the Peer object.
This dates back to version 0.2.0 which was released on 2013-03-24. It sounds like the 'error' event is not triggered by PeerConnection objects anymore but instead the 'error' handler of the corresponding Peer object is invoked instead. However, the 'error' event is still listed in the official API documentation for PeerConnections and I didn't observe the Peer's error handler being called when the connection got lost.
Problem persists in version 1.5.4. Neither the 'error' handler of the PeerConnection nor the one of the Peer object is called. Maybe a duplicate of #626.