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

Add option to time request/response cycle (including rollup of redirects) #1459

Merged
merged 4 commits into from Mar 13, 2015

Conversation

aaron-em
Copy link
Contributor

@aaron-em aaron-em commented Mar 5, 2015

Sure, it'd be fairly trivial to grab timestamps before initiating the request, and in the response callback, and compare them; on the other hand, I'll eventually have a lot of tests where I want to use the functionality, and writing a wrapper around the request library doesn't appeal to me.

@nickmccurdy
Copy link
Contributor

👍 It seems like your new test is broken though.

@aaron-em aaron-em closed this Mar 5, 2015
@aaron-em aaron-em reopened this Mar 5, 2015
@aaron-em
Copy link
Contributor Author

aaron-em commented Mar 5, 2015

@nicolasmccurdy Good catch, thanks! Odd that that assertion passes locally but fails in CI - in any case, the check around the mock delay on redirect renders the failing assertion moot, so I just removed it.

@nickmccurdy
Copy link
Contributor

👍

@seanstrom
Copy link
Contributor

The original tests sometimes fail for me.
I notice the failing spec is testing that the non-redirected request is faster than a request that is redirected. Was that the intent?

@seanstrom
Copy link
Contributor

If you still want that test you would probably need to increase the redirect_mock_time to at least 20ms.
I think 10ms is too low for setTimeout, possible the V8 isn't accurate enough for 10ms?

Update: more specifically Node's setTimeout may not be that accurate.

@aaron-em
Copy link
Contributor Author

I doubt it's a V8 issue since the test was reliable locally, and only failed in CI.

Aaron Miller
Mobile: (443) 810-0023
me@aaron-miller.me
http://aaron-miller.me

On Mar 10, 2015, at 22:30, Sean Hagstrom notifications@github.com wrote:

If you still want that test you would probably need to increase the redirect_mock_time to at least 20ms.
I think 10ms is too low for setTimeout, possible the V8 isn't accurate enough for 10ms?


Reply to this email directly or view it on GitHub.

@aaron-em
Copy link
Contributor Author

Not really; the intent was to ensure that, when following redirects, the time reported is the sum of all request times, instead of only the time taken by the last request made.

Aaron Miller
Mobile: (443) 810-0023
me@aaron-miller.me
http://aaron-miller.me

On Mar 10, 2015, at 22:23, Sean Hagstrom notifications@github.com wrote:

The original tests sometimes fail for me.
I notice the failing spec is testing that the non-redirected request is faster than a request that is redirected. Was that the intent?


Reply to this email directly or view it on GitHub.

@seanstrom
Copy link
Contributor

What I was getting at is that running your original test locally for me was not reliable, it would fail or succeed on and off.

@seanstrom
Copy link
Contributor

The original test was just checking the redirect elapsed time was greater than the non redirect elapsed time right? Not the sum of each request's elapsed time correct?

@seanstrom
Copy link
Contributor

I've also have had different results depending on the order of the tests.

self.req = self.httpModule.request(reqOptions)

if (self.timing) {
self.startTime = startTime
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we just define self.startTime to be new Date().getTime() ?

@seanstrom
Copy link
Contributor

@nylen @simov @FredKSchott Do you guys have any opinion about adding this?
I'm thinking it would be a good idea.

@aaron-em aaron-em closed this Mar 11, 2015
@aaron-em aaron-em reopened this Mar 11, 2015
@seanstrom
Copy link
Contributor

Seems like the tests are failing because an error that was thrown by Karma Spec Runner

Update: And only in Node 0.12

@aaron-em
Copy link
Contributor Author

@seanstrom this is my first experience with travis; i have no idea what to do about that, sorry.

@nickmccurdy
Copy link
Contributor

It seems to me like this might be an issue with Karma occasionally failing on Travis. Could someone please restart the job so we can see if that helps?

@seanstrom
Copy link
Contributor

That's okay, i just wanted that info to stated on the PR.
That way it doesn't seem like your tests were failing or Request's tests were failing.

@seanstrom
Copy link
Contributor

I attempted to restart the build, and Travis says the job has been restarted.
But I get no visualization of the restart being in process. Does anyone else know how Travis restart works?

@seanstrom seanstrom closed this Mar 11, 2015
@seanstrom seanstrom reopened this Mar 11, 2015
@seanstrom
Copy link
Contributor

Okay so closing and opening the PR will restart the PR build in Travis CI

@seanstrom
Copy link
Contributor

@aaron-em okay everything looks good, but I made one other line comment.
After that's addressed we should be good.

@simov
Copy link
Member

simov commented Mar 12, 2015

@seanstrom I don't think this should be part of the core as it doesn't add any value to the module. You can wrap request in a function and achieve the exact same result without passing additional option to request itself.

But if you want it merge it, it's your call :)

@simov
Copy link
Member

simov commented Mar 12, 2015

Actually now when I think about it, why not, we have tons of other options as well. So @seanstrom I'm not against adding it.

@seanstrom
Copy link
Contributor

@simov yeah that was my feeling at first, but like you said we have a bunch of useful options.
I could see it being a useful utility to have around.

@seanstrom
Copy link
Contributor

@aaron-em any other changes you want to make?
Im ready to merge this unless anyone else has objections

@aaron-em
Copy link
Contributor Author

I've done all the damage I mean to do; feel free to merge, and thanks!

Aaron Miller
Mobile: (443) 810-0023
me@aaron-miller.me
http://aaron-miller.me

On Mar 12, 2015, at 19:46, Sean Hagstrom notifications@github.com wrote:

@aaron-em any other changes you want to make?
Im ready to merge this unless anyone else has objections


Reply to this email directly or view it on GitHub.

seanstrom added a commit that referenced this pull request Mar 13, 2015
Add option to time request/response cycle (including rollup of redirects)
@seanstrom seanstrom merged commit 5e7b73d into request:master Mar 13, 2015
@seanstrom
Copy link
Contributor

@simov do you have access to publish the module or is that just @nylen ?

@simov
Copy link
Member

simov commented Mar 13, 2015

@seanstrom check out the names listed below the maintainers section here https://www.npmjs.com/package/request

@pungoyal
Copy link

when do we expect an npm release for this? it would be very helpful for us.

@simov
Copy link
Member

simov commented Mar 23, 2015

The next release on NPM is scheduled for this week, I'll post an issue in the tracker when it's done 👍

@pungoyal
Copy link

👍 look forward

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.

None yet

5 participants