Skip to content

Disconnect right after emit will eat the emit #53

@spthiel

Description

@spthiel

When calling emit right before disconnect the emit will not be sent to the server making it unpredictable behaviour.

E.g. following code:

import ipc from "node-ipc";

ipc.config.id = "foo";

ipc.serve(() => {

    ipc.config.id = "bar";

    ipc.connectTo("foo", () => {
        ipc.of["foo"].emit("test", "test");
        ipc.disconnect("foo");
    })
})

ipc.server.on("test", console.log);
ipc.server.start();

will never log. In the debug output it shows

  1. (server) Starting server as Unix || Windows Socket
  2. (client) requested connection to foo
  3. (client) connecting to foo
  4. (client) dispatch event
  5. (client) close connection
  6. (server) socket disconnected

This behaviour is required because I want one of the possible execution paths to send a single message to the server and then close the application (other paths would use the socket as a long time connection)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions