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

Fix request timeout no working #802

Merged
merged 4 commits into from
Feb 27, 2017
Merged

Fix request timeout no working #802

merged 4 commits into from
Feb 27, 2017

Conversation

aleung
Copy link
Contributor

@aleung aleung commented Jan 18, 2017

This PR fixed #754 and #739

There are two changes:

  1. Set socket.connecting to true to allow request module creates timeout timer.
  2. Emit ClientRequest.connect event after connection delay, just before sending response. Before modification, it emits too early and make request module clears the connection timeout timer.

@coveralls
Copy link

coveralls commented Jan 18, 2017

Coverage Status

Coverage increased (+0.0007%) to 96.538% when pulling 5701fa6 on aleung:fix-754 into 9ee2984 on node-nock:master.

@aleung
Copy link
Contributor Author

aleung commented Jan 18, 2017

Updated a failed test case which covers Restify use case #79.

In that test case the ClientRequest ends until connect event is received. But actually Restify ends the req on socket event. The test case was incorrect.

See #79 (comment)

@ianwsperber
Copy link
Contributor

Thanks for working on this @aleung. Could you add a test case asserting the new behavior?

@coveralls
Copy link

coveralls commented Jan 24, 2017

Coverage Status

Coverage increased (+0.0007%) to 96.538% when pulling 39afb7e on aleung:fix-754 into f6d3e76 on node-nock:master.

@aleung
Copy link
Contributor Author

aleung commented Jan 24, 2017

@ianwsperber The test case was there (test_timeout.js). It started failing with request v2.76.0 (see this comment). The test suite used request v2.71.0 which won't fail even before my fix. I have pushed a commit to update it to v2.79.0.

@ianwsperber
Copy link
Contributor

@aleung Because I'm new to the project I would like to wait on feedback from @vrinek or others before continuing. If we don't get any additional feedback within the week we can move this PR forward ourselves. Thanks!

@coveralls
Copy link

coveralls commented Feb 15, 2017

Coverage Status

Coverage increased (+0.005%) to 92.666% when pulling 343dc5d on aleung:fix-754 into 5856cde on node-nock:master.

@aleung
Copy link
Contributor Author

aleung commented Feb 15, 2017

@ianwsperber Can we go forward? I just rebase my fix to master latest.

@ianwsperber
Copy link
Contributor

Would feel more confident if we already had #832. I will merge in the next few days @aleung, once we're confident 9.0.7 is settled

@ianwsperber ianwsperber modified the milestones: 9.0.6, 9.0.7 Feb 23, 2017
@@ -3,3 +3,4 @@ npm-debug.log
coverage
.nyc_output/
tests/browserify-public/browserify-bundle.js
.vscode/

Choose a reason for hiding this comment

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

~/.gitignore is a place for that

@@ -194,8 +195,6 @@ function RequestOverrider(req, options, interceptors, remove, cb) {
// emit a fake socket.
if (event == 'socket') {
listener(req.socket);
req.socket.emit('connect', req.socket);
Copy link
Contributor

Choose a reason for hiding this comment

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

@aleung Are you sure we don't need to emit a connect event here anymore? Might this cause a regression of #79?

@ianwsperber ianwsperber modified the milestones: 9.0.7, version-tests Feb 27, 2017
@ianwsperber ianwsperber merged commit 3f26630 into nock:master Feb 27, 2017
@ianwsperber
Copy link
Contributor

Thanks for your help and patience on this one @aleung. Your changes will go out in v9.0.8 today.

@matteocontrini
Copy link

I think this broke something.
I have a test that uses socketDelay to test request timeouts and it started failing after updating to 9.0.8.
I haven't tried to isolate the issue yet, but it should look like this:

nock('http://myservice.it')
	.get('/')
	.query(true)
	.socketDelay(2000)
	.reply(400);
request({ url: 'http://myservice.it/?something', timeout: 1000 }, (err) => {
	// err is falsy
});

@lpinca
Copy link
Contributor

lpinca commented Feb 28, 2017

I hit the same issue. socketDelay() no longer works.

@ianwsperber
Copy link
Contributor

Thanks @matteocontrini & @lpinca, I've created #839 to track the bug.

ianwsperber added a commit that referenced this pull request Feb 28, 2017
aleung pushed a commit to aleung/nock that referenced this pull request Mar 21, 2017
aleung pushed a commit to aleung/nock that referenced this pull request Mar 21, 2017
@lock
Copy link

lock bot commented Sep 13, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue and add a reference to this one if it’s related. Thank you!

@lock lock bot locked as resolved and limited conversation to collaborators Sep 13, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants