Skip to content

net.Socket.connect often fails from the renderer process until the window is reloaded. Ubuntu 20.04 (Win/Mac seem fine) #27127

Closed as not planned

Description

@koush
  • [ x] I have read the Contributing Guidelines for this project.
  • [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.

Activity

  1. pgherveou commented on May 13, 2021

    @pgherveou

    👋 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...

  2. koush commented on May 13, 2021

    @koush
    Author

    I'm still on 9.4.0 unfortunately. Can't upgrade until this is fixed. It's too severe for my app.

  3. koush commented on Jun 6, 2021

    @koush
    Author

    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)

    image

  4. koush commented on Jun 6, 2021

    @koush
    Author

    After some further poking, initiating another connection seems to push the pending events through, as if the event loop is stuck?

  5. koush commented on Jun 6, 2021

    @koush
    Author

    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.

  6. nornagon commented on Jun 22, 2021

    @nornagon
    Contributor

    Is this still happening on 12.0.12 or 13.1.3?

  7. koush commented on Jun 22, 2021

    @koush
    Author

    It was still happening in 13.1.2. I'll check 13.1.3 shortly.

  8. koush commented on Jun 22, 2021

    @koush
    Author

    Was there a change you think addressed this issue or are you just asking for an update?

  9. nornagon commented on Jun 22, 2021

    @nornagon
    Contributor

    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.

  10. pgherveou commented on Jun 22, 2021

    @pgherveou

    Did the nodejs version changed in the latest 13.x electron releases? If not these libuv changes would not be picked up right?

  11. koush commented on Jun 23, 2021

    @koush
    Author

    I can confirm this still occurs on 13.1.4 (which apparently was released today).

  12. pgherveou commented on Jun 23, 2021

    @pgherveou

    @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.

  13. koush commented on Jun 23, 2021

    @koush
    Author

    @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.

  14. github-actions commented on Oct 6, 2022

    @github-actions
    Contributor

    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!

  15. github-actions commented on Nov 5, 2022

    @github-actions
    Contributor

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions