Skip to content

Fix "process.hrtime() only accepts an Array tuple." error. - #922

Merged
Rich-Harris merged 4 commits into
rollup:masterfrom
lemmabit:hrtime-error
Sep 11, 2016
Merged

Fix "process.hrtime() only accepts an Array tuple." error.#922
Rich-Harris merged 4 commits into
rollup:masterfrom
lemmabit:hrtime-error

Conversation

@lemmabit

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

2 participants