You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
net.Socket.connect often fails from the renderer process until the window is reloaded. Ubuntu 20.04 (Win/Mac seem fine) #27127
[x ] I agree to follow the Code of Conduct that this project adheres to.
[ x] I have searched the issue tracker for an issue that matches the one I want to file, without success.
Issue Details
Using net.Socket.connect from a renderer process does often not work until the renderer has been reloaded (ie, window.reload). Subsequent connect calls work fine. The connect event is never emitted. Neither is the connection failure or error events.
Electron Version:
10.x+ (tested up to 12.x)
Operating System:
Ubuntu 20.04
Last Known Working Electron version:
9.4.0
Expected Behavior
The connect event should be emitted. The socket should connect.
Actual Behavior
The socket hangs waiting for connect.
To Reproduce
Connect to a localhost socket (in another process) from the renderer process on Ubuntu 20.04
Screenshots
None
Additional Information
This seems to happen fairly reliably, and does NOT happen on 9.4.0 I tried switching app.allowRendererProcessReuse to false, but that did not seem to fix it.
👋 we are noticing similar behaviors on mac running latest electron version (12.0.5)
Did you have more success running these sockets directly in the main thread instead?
One thing I noticed from users reporting the bug is that lsof -i tcp:443 | grep <app-name>
Report connection in CLOSED or CLOSE_WAIT status.
Apart from that, I am not sure yet what the best way to debug these issues...
Revisited this, and in my case lsof is showing the localhost connection as established, but the connection event on the node socket has never fired. I can check the state of the socket, and it remains at "connecting". electron 13.0.1. window reload no longer resolves this issue.
electron 8962 koush 57u IPv4 228454 0t0 TCP localhost:59830->localhost:5037 (ESTABLISHED)
I've managed to "fix" this issue by having a socket connect to a localhost server (within the same process), and just periodically sending ping packets. This seemingly prevents the net loop from hanging for whatever reason.
@koush have you been able to test whether or not webworker with Node integration suffer from the same issue.
I ran some quick tests with our users experiencing this, and it seems that webworker can still open socket when the renderer thread fails to do so.
@koush have you been able to test whether or not webworker with Node integration suffer from the same issue.
I ran some quick tests with our users experiencing this, and it seems that webworker can still open socket when the renderer thread fails to do so.
I tried enabling node in web worker, and was getting renderer (native?) crashes, so I disabled it.
This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the latest version of Electron or in the beta—please include it with your comment!
This issue has been closed due to inactivity, and will not be monitored. If this is a bug and you can reproduce this issue on a supported version of Electron please open a new issue and include instructions for reproducing the issue.
Activity
pgherveou commentedon May 13, 2021
👋 we are noticing similar behaviors on mac running latest electron version (12.0.5)
Did you have more success running these sockets directly in the main thread instead?
One thing I noticed from users reporting the bug is that
lsof -i tcp:443 | grep <app-name>Report connection in CLOSED or CLOSE_WAIT status.
Apart from that, I am not sure yet what the best way to debug these issues...
koush commentedon May 13, 2021
I'm still on 9.4.0 unfortunately. Can't upgrade until this is fixed. It's too severe for my app.
koush commentedon Jun 6, 2021
Revisited this, and in my case lsof is showing the localhost connection as established, but the connection event on the node socket has never fired. I can check the state of the socket, and it remains at "connecting". electron 13.0.1. window reload no longer resolves this issue.
koush commentedon Jun 6, 2021
After some further poking, initiating another connection seems to push the pending events through, as if the event loop is stuck?
koush commentedon Jun 6, 2021
I've managed to "fix" this issue by having a socket connect to a localhost server (within the same process), and just periodically sending ping packets. This seemingly prevents the net loop from hanging for whatever reason.
This is awful but I need to get off Electron 9.
nornagon commentedon Jun 22, 2021
Is this still happening on 12.0.12 or 13.1.3?
koush commentedon Jun 22, 2021
It was still happening in 13.1.2. I'll check 13.1.3 shortly.
koush commentedon Jun 22, 2021
Was there a change you think addressed this issue or are you just asking for an update?
nornagon commentedon Jun 22, 2021
There were a few libuv changes that happened recently-ish, so I wanted to get a sense for whether any of those might have had an effect.
pgherveou commentedon Jun 22, 2021
Did the nodejs version changed in the latest 13.x electron releases? If not these libuv changes would not be picked up right?
koush commentedon Jun 23, 2021
I can confirm this still occurs on 13.1.4 (which apparently was released today).
pgherveou commentedon Jun 23, 2021
@koush have you been able to test whether or not webworker with Node integration suffer from the same issue.
I ran some quick tests with our users experiencing this, and it seems that webworker can still open socket when the renderer thread fails to do so.
koush commentedon Jun 23, 2021
I tried enabling node in web worker, and was getting renderer (native?) crashes, so I disabled it.
github-actions commentedon Oct 6, 2022
This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the latest version of Electron or in the beta—please include it with your comment!
github-actions commentedon Nov 5, 2022
This issue has been closed due to inactivity, and will not be monitored. If this is a bug and you can reproduce this issue on a supported version of Electron please open a new issue and include instructions for reproducing the issue.