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

Allow plugin "stateful" disconnection/exit. #36

Merged
merged 3 commits into from
Sep 1, 2023
Merged

Conversation

mpaperno
Copy link
Collaborator

@mpaperno mpaperno commented Aug 31, 2023

  • Adds 'exitOnClose' option to connect() method to control if client automatically calls process.exit(0) upon socket error/close (default is true).
  • Adds 'disconnected' event with hadError <boolean> parameter passed on from socket's 'close' event (true if the socket had a transmission error).
  • Adds 'socketError' event with err <Error> parameter passed on from socket's 'error' event.
  • Adds disconnect() method which closes any current connection with socket.end().
  • We don't need to exit() from multiple locations since socket's 'close' event is going to be fired regardless.

Just to note, if the only thing keeping the Node process active is the open socket to TP, then the plugin/program will exit anyway once the socket is closed/errors, regardless of the new 'exitOnClose' option. The only thing this option controls is literally if process.exit(0) is called automatically upon disconnection (or lack of successful connection in the first place).

@mpaperno mpaperno added the enhancement New feature or request label Aug 31, 2023
@mpaperno mpaperno requested a review from spdermn02 August 31, 2023 17:24
Copy link
Owner

@spdermn02 spdermn02 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants