Skip to content
This repository was archived by the owner on Aug 20, 2024. It is now read-only.

Add connectTimeout option#26

Merged
nsimmons merged 1 commit into
nsimmons:masterfrom
jgodson:master
Oct 20, 2020
Merged

Add connectTimeout option#26
nsimmons merged 1 commit into
nsimmons:masterfrom
jgodson:master

Conversation

@jgodson

@jgodson jgodson commented Oct 15, 2020

Copy link
Copy Markdown
Contributor

This adds a new option to supply a separate timeout for a connection to be made. This allows you to fail fast if there are dns or network issues if you need a longer timeout in general (or don't want to set a timeout at all)

// reject(error);
if (err.code === 'ECONNRESET') {
ctx.set('X-Timout-Reason', 'koa-better-http-proxy timed out your request after ' + options.timeout + 'ms.');
ctx.set('X-Timout-Reason', 'koa-better-http-proxy timed out your request after ' + timeoutDuration + 'ms.');

@jgodson jgodson Oct 15, 2020

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

There's a typo in this header, but that could be a breaking change technically so I left it alone

Comment thread test/connectTimeout.js

describe('when connectTimeout option is set lower than server connect time', function() {
it('should fail with CONNECTION TIMEOUT', function(done) {
http.use(proxy('http://127.0.0.0', {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I wanted to find a seemingly more "legit" way to make this happen, but I couldn't and this seems to work 🤷‍♂️

@nsimmons nsimmons merged commit 5fe48ae into nsimmons:master Oct 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants