request-capture-har icon indicating copy to clipboard operation
request-capture-har copied to clipboard

response.request doesn't have a startTime property, causing request() to crash

Open Maciek416 opened this issue 8 years ago • 4 comments

I'm getting some confusing behavior and I'm not sure why exactly.

Node / Package versions:

Repro source:

var RCH = require("request-capture-har");
var requestCaptureHar = new RCH(require("request"));

requestCaptureHar.request("https://saucelabs.com/rest/v1/info/platforms/all?resolutions=true", function (error, res, body) {
  console.log("done");
});

Output when running:

/Users/madwent/projects/testarmada/magellan-admiral2-plugin/node_modules/request-capture-har/request-capture-har.js:82
  entry.startedDateTime = new Date(startTs).toISOString();
                                            ^

RangeError: Invalid time value
    at HarWrapper.buildTimings (/Users/madwent/projects/testarmada/magellan-admiral2-plugin/node_modules/request-capture-har/request-capture-har.js:82:45)
    at HarWrapper.buildHarEntry (/Users/madwent/projects/testarmada/magellan-admiral2-plugin/node_modules/request-capture-har/request-capture-har.js:138:8)
    at Request._callback (/Users/madwent/projects/testarmada/magellan-admiral2-plugin/node_modules/request-capture-har/request-capture-har.js:40:30)
    at Request.self.callback (/Users/madwent/projects/testarmada/magellan-admiral2-plugin/node_modules/request/request.js:188:22)
    at emitTwo (events.js:106:13)
    at Request.emit (events.js:191:7)
    at Request.<anonymous> (/Users/madwent/projects/testarmada/magellan-admiral2-plugin/node_modules/request/request.js:1171:10)
    at emitOne (events.js:96:13)
    at Request.emit (events.js:188:7)
    at IncomingMessage.<anonymous> (/Users/madwent/projects/testarmada/magellan-admiral2-plugin/node_modules/request/request.js:1091:12)

Looking at HarWrapper.prototype.buildTimings, it appears that my response.request doesn't have a startTime property. I'm not sure why.

My response.request object seems to be missing more than one property that the fixtures in your tests expect. I've got a sample of the object in a gist here (note: large JSON response body removed for brevity): https://gist.github.com/Maciek416/d0aac3965840677e0c475872d58adc4e

[edit: platform is OS X 10.11.6]

Maciek416 avatar Jun 01 '17 23:06 Maciek416

Same problem here (64bit linux, node-6.11.1, request-2.83.0, request-capture-har-1.2.2)

fpauser avatar Sep 29 '17 14:09 fpauser

bump

usmonster avatar Jul 16 '18 16:07 usmonster

I am facing same issue. Have you found resolution for it?

pawanjitghatora avatar Jan 29 '19 06:01 pawanjitghatora

Same issue , not able to generate har file get invalid time value. Did anyone get other solution for this, please guide me

rarunp04 avatar May 21 '20 15:05 rarunp04