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 "process.hrtime() only accepts an Array tuple." error. #922

Merged
merged 4 commits into from
Sep 11, 2016

Conversation

lemmabit
Copy link
Contributor

I was upgrading the version of Rollup used by gulp-rollup when suddenly almost all of my tests started failing on Travis with the error process.hrtime() only accepts an Array tuple..

Turns out Rollup had been updated again while I was working, introducing this error. Tracking that down was fun. So here's a fix—enjoy.

@lemmabit lemmabit mentioned this pull request Sep 11, 2016
@Rich-Harris
Copy link
Contributor

Thanks! That's weird – what version of Node is that with? On Node 6, process.hrtime(undefined) works exactly as expected (i.e. the same as process.hrtime().

Rather than redefining toMilliseconds, how about just changing this function to something like this?

time = function time ( previous ) {
    if ( previous ) {
        const hrtime = process.hrtime( previous );
        return hrtime[0] * 1e3 + hrtime[1] / 1e6;
    }

    return process.hrtime();
};

@lemmabit
Copy link
Contributor Author

It's Node 4.

It seems rather odd to me to have one function do pretty much unrelated things depending on whether or not you pass it an argument. I'm not sure what to call the split-up time function without sounding redundant with timeStart and timeEnd... I think timeStartHelper and timeEndHelper would be descriptive.

@lemmabit
Copy link
Contributor Author

Alright, I split up time using those names.

@Rich-Harris Rich-Harris merged commit f4a7256 into rollup:master Sep 11, 2016
@Rich-Harris
Copy link
Contributor

LGTM, thanks 👍

It seems rather odd to me to have one function do pretty much unrelated things depending on whether or not you pass it an argument

I agree, but the Node.js people apparently don't 😀 I guess we were just following their lead

@lemmabit lemmabit deleted the hrtime-error branch September 11, 2016 01:21
@Rich-Harris
Copy link
Contributor

Released 0.35.7

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

2 participants