Skip to content

Simplify state handling internals - #847

Merged
arthurschreiber merged 3 commits into
masterfrom
arthur/cleanup-states
Jan 16, 2019
Merged

arthurschreiber merged 3 commits into
masterfrom
arthur/cleanup-states

Conversation

@arthurschreiber

Copy link
Copy Markdown
Collaborator

These changes are slightly reworking some internal details of how the logic for handling different states is organized.

There's a few specific things I tried to do here:

  • Remove the number of .dispatchEvent calls and state specific event handler code. In all the places I changed, the indirection this introduced made the code harder to understand, and was absolutely not necessary.
  • Remove process.nextTick calls that were not necessary. These required code to be changed to be async, even though these process.nextTick calls were not even required.
  • Remove SENT_NTLM_RESPONSE state. There is no state like this described in the MS-TDS specification, instead this logic happens as part of SENT_LOGIN7_WITH_NTLM, so I merged those two together.

Currently, the logic that governs what is happening in the `Connection` 
while the connection is in a specific state is spread over different 
methods, callbacks and internal events, sometimes with 
`process.nextTick` calls sprinkled in for good measure. This often makes 
this code, it's logic and the state transitions much harder to 
understand than required.

By inlining some of the method calls and removing some internal events, 
we can clean up and simplify this code, without impacting any 
functionality.
This state is not specified in the MS-TDS specification, and it does not 
serve any clear purpose. It can be merged with the 
`SENT_LOGIN7_WITH_NTLM` state.
@arthurschreiber

Copy link
Copy Markdown
Collaborator Author

🎉 This PR is included in version 5.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant