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

on("error") callback function is never executed. #994

Open
allanbbs opened this issue Aug 23, 2022 · 4 comments
Open

on("error") callback function is never executed. #994

allanbbs opened this issue Aug 23, 2022 · 4 comments
Labels
bug client related to peerjs client missing info more information needed

Comments

@allanbbs
Copy link

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?

@jonasgloning
Copy link
Member

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?

@jonasgloning jonasgloning added bug missing info more information needed labels Sep 6, 2022
@irgalamarr irgalamarr added the client related to peerjs client label Feb 24, 2024
@nikur
Copy link

nikur commented May 29, 2024

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!

@nikur
Copy link

nikur commented May 29, 2024

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.

@nikur
Copy link

nikur commented May 29, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug client related to peerjs client missing info more information needed
Projects
None yet
Development

No branches or pull requests

4 participants