New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 801306 link

Starred by 8 users

Issue metadata

Status: Duplicate
Merged: issue 817970
Owner:
Last visit > 30 days ago
Closed: Apr 2018
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Mac
Pri: 2
Type: Bug-Regression



Sign in to add a comment

Extension api - devtools.network.onRequestFinished registered handler won't get called for some requests

Reported by itsgoi...@luzer.sk, Jan 11 2018

Issue description

UserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_2) AppleWebKit/604.4.7 (KHTML, like Gecko) Version/11.0.2 Safari/604.4.7

Steps to reproduce the problem:
1. use devtools.network.onRequestFinished api to register a handler to be executed for all executed requests in a Chrome extension
2. the handler won't be called in many cases, with internal dev tools code crash being logged

What is the expected behavior?

What went wrong?
Recently a bug was introduced where the browser won't call devtools.network.onRequestFinished handler for some requests.

Following exception is reported in the dev tools for the extension:

TypeError: targetDate.getTime is not a function TypeError: targetDate.getTime is not a function
    at SDK.Cookie.expiresDate (inspector.js:3602)
    at NetworkLog.HAREntry._buildCookie (inspector.js:6016)
    at Array.map (<anonymous>)
    at NetworkLog.HAREntry._buildCookies (inspector.js:6015)
    at NetworkLog.HAREntry._buildResponse (inspector.js:6002)
    at NetworkLog.HAREntry.build (inspector.js:5996)
    at Extensions.ExtensionServer._notifyRequestFinished (inspector.js:7404)
    at SDK.NetworkManager.dispatchEventToListeners (inspector.js:482)
    at SDK.NetworkDispatcher._finishNetworkRequest (inspector.js:5664)
    at SDK.NetworkDispatcher.loadingFinished (inspector.js:5637)

Taking a quick look at the source, looks like this was introduced in a recent change, where the `NetworkLog.HARLog.pseudoWallTime` function was changed to return date as string instead of Date instance - https://github.com/ChromeDevTools/devtools-frontend/commit/96e7acf5393f0aa456017506d3fd382e5fbdf014

But the `SDK.Cookie.expiresDate` expects to be called with a Date instance - https://github.com/ChromeDevTools/devtools-frontend/blob/master/front_end/sdk/CookieParser.js#L325

It's called here - https://github.com/ChromeDevTools/devtools-frontend/blob/master/front_end/network_log/HAREntry.js#L269

Did this work before? Yes 

Chrome version: 65.0.3318.0  Channel: canary
OS Version: OS X 10.13.2
Flash Version:
 
Labels: Needs-Triage-M65
Cc: krajshree@chromium.org
Labels: Triaged-ET Needs-Feedback
itsgoingd@ - Thanks for filing the issue...!!

Could you please provide a sample extension file/test file to test the issue from TE-end.
this will help us in triaging the issue further.

Thanks...!! 
Labels: -Pri-2 Pri-1
Owner: eostroukhov@chromium.org
Status: Assigned (was: Unconfirmed)
Labels: -Pri-1 Pri-2

Comment 5 by wdcr...@gmail.com, Mar 19 2018

I'm seeing this as well when I try to use the network.getHar() function or the network.onRequestFinished.addListener() function. Unfortunately it's breaking my company's ad debugging plugin. It seems the NetworkLog.HARLog.pseudoWallTime() is returning a date String rather than a Date. Then the expiresDate function in SDK.Cookie calls getTime() on that string and throws an error.
Screen Shot 2018-03-19 at 1.21.21 PM.png
227 KB View Download

Comment 6 by tie...@gmail.com, Mar 20 2018

I met same issue.
Chrome version: 65.0.3325.162 (Official Build). Channel: stable
OS: Windows 10 build 1709

It occures when Set-Cookie response header has max-age (RFC 6265).
If the header has expires instead of max-age, no errors happen.
IMO, first report is correct.

I created a minimal reproduce code.

1. install this extension: https://gist.github.com/Tietew/b77778b67af8e66299a62a40b78e8598
2. open blank tab
3. open devtool
4. open devtool's devtool
5. navigate to: https://9rr7ehinag.execute-api.ap-northeast-1.amazonaws.com/test/chromium801306
6. console of devtool's devtool (4) shows following error

TypeError: targetDate.getTime is not a function TypeError: targetDate.getTime is not a function
    at SDK.Cookie.expiresDate (inspector.js:3603)
    at NetworkLog.HAREntry._buildCookie (inspector.js:6023)
    at Array.map (<anonymous>)
    at NetworkLog.HAREntry._buildCookies (inspector.js:6022)
    at NetworkLog.HAREntry._buildResponse (inspector.js:6009)
    at NetworkLog.HAREntry.build (inspector.js:6003)
    at Extensions.ExtensionServer._notifyRequestFinished (inspector.js:7414)
    at SDK.NetworkManager.dispatchEventToListeners (inspector.js:482)
    at SDK.NetworkDispatcher._finishNetworkRequest (inspector.js:5671)
    at SDK.NetworkDispatcher.loadingFinished (inspector.js:5644)

Comment 7 by tie...@gmail.com, Mar 26 2018

This issue has been fixed by https://bugs.chromium.org/p/chromium/issues/detail?id=817970
Right?

Comment 8 by rasy...@gmail.com, Mar 30 2018

I confirmed the same bug with version: 65.0.3325.181.
When is the corrected?
I have written a chrome extension. This extension uses
devTools.network.onRequestFinished.addListener(function(request) {...}

Flow was working as expected and request were captured by listener appropriately till version 64.x

Unfortunately, with the newer version of Google Chrome - Version 65.0.3325.181 (Official Build) (64-bit), this functionality seems to be broken.

Now, I am getting javascript errors. Please refer to the attached text file for reference.

Will be great if someone can please take a look and provide your comments.

Thanks for all your help in advance.
error.txt
34.2 KB View Download
I've updated my extension to use the `webRequest` api instead since reporting this issue, as it wasn't going to be fixed before a stable channel release.

It's pretty straight-forward and also supported in Firefox, example implementation - https://github.com/itsgoingd/clockwork-chrome/blob/master/Clockwork%20Chrome/assets/javascripts/chrome/background.js#L44-L59, https://github.com/itsgoingd/clockwork-chrome/blob/master/Clockwork%20Chrome/assets/javascripts/extension.js#L49-L80
Mergedinto: 817970
Status: Duplicate (was: Assigned)

Sign in to add a comment