Skip to content

Feature/cancellation timer - #566

Closed
gsterjov wants to merge 5 commits into
tediousjs:masterfrom
htdc:feature/cancellation-timer
Closed

gsterjov wants to merge 5 commits into
tediousjs:masterfrom
htdc:feature/cancellation-timer

Conversation

@gsterjov

Copy link
Copy Markdown

No description provided.

@gsterjov

Copy link
Copy Markdown
Author

Mainly to address the issue at: #357

Adds a cancellation timeout which will close the connection once elapsed. Request timeouts will also call this.cancel() rather than going straight to SentAttention, so a request timeout with a failed cancellation will close the connection

@arthurschreiber

Copy link
Copy Markdown
Collaborator

@gsterjov I just fixed an issue with stack traces being incorrect for tests written in Coffee Script (see #567). Would you mind merging in the latest master changes or rebasing your changes on top of master? That would help figure out what test cases exactly are failing the Travis and AppVeyor builds.

Comment thread src/connection.js Outdated

cancelTimeout() {
this.cancelTimer = undefined;
return this.close();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I don't think the return here is necessary.

Also, on top of that, I'm not sure whether just calling this.close is the best course of action here. The in-flight request that did not get cancelled in time will get a RequestError, but it will not be clear that this error was passed because cancellation timed out.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Good point. I'll try get it to return an appropriate error message

Comment thread src/connection.js
this.requestTimer = undefined;
this.messageIo.sendMessage(TYPE.ATTENTION);
return this.transitionTo(this.STATE.SENT_ATTENTION);
this.cancel();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This will set canceled=true which in turn will cause the error message to be Canceled instead of Timeout. You should have three different error messages for the three different cases - user initiated cancel(), request timer timeout and cancel timer timeout (i.e. timeout waiting for Attention acknowledgement)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

There are actually two flavors of cancel timer timeout error messages:

  1. Attention sent in response to request timeout.
  2. Attention sent in response to user initiated cancel()

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Great, thanks for the help! I'm thinking its possible to still have the single cancel timer but to stick some bool flags to determine what kind of cancellation it is.

Comment thread src/connection.js
this.socketError = this.socketError.bind(this);
this.requestTimeout = this.requestTimeout.bind(this);
this.connectTimeout = this.connectTimeout.bind(this);
this.cancelTimeout = this.cancelTimeout.bind(this);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

A test would be nice though I can't think of a way to add it...

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I'll see what I can do. Might be a bit contrived but at the very least it would be good to test the various types of cancellation

ihgrant pushed a commit to ihgrant/tedious that referenced this pull request Feb 27, 2018
@ihgrant

ihgrant commented Mar 1, 2018

Copy link
Copy Markdown

As far as I can tell, this patch fixes a serious bug that my team was experiencing in production with the mssql package that depends on this library.

Is there anything I can do to help get this PR merged?

@arthurschreiber

Copy link
Copy Markdown
Collaborator

@ihgrant Thanks for the ping. I'll take a look and will try to get this merged asap! ❤️

@arthurschreiber

Copy link
Copy Markdown
Collaborator

The cancellation rework in #846 also implements a proper request cancellation timer. 👍

@gsterjov

Copy link
Copy Markdown
Author

Nice!

@gsterjov gsterjov closed this Jan 16, 2019
@arthurschreiber

Copy link
Copy Markdown
Collaborator

@gsterjov Your review on #846 would be greatly appreciated! 🙇

@arthurschreiber

Copy link
Copy Markdown
Collaborator

🎉 This issue has been resolved 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.

4 participants