Skip to content

sendClose hangs for 10 seconds before fulfilling #9

@taylor1791

Description

@taylor1791

While using node-volapi I noticed that it takes a while for the node process to terminate. I tracked it down to the following lines in sendClose. It appears that the timer from deadline is still in node's task queue.

      const send = promisify(this.eio.send.bind(this.eio));
      await Promise.race([
        deadline(10 * 1000),
        send(call, null)
      ]);

While playing around, I replaced those lines with these and it appeared to fix it. I didn't make an MR since this appears to be a pretty common error throughout and I don't know how you want your abstractions.

      await new Promise((resolve, reject) => {
        const timeout = setTimeout(() => {
          done(new VolaError("Disconnect timeout"), null);
        }, 10 * 1000);

        this.eio.send(call, null, done);

        function done(err, data) {
          clearTimeout(timeout);

          if (err) return reject(err);
          resolve(data);
        }
      });

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions