XMLHttp is sending two buffers to server
Reported by
richb...@gmail.com,
Dec 26
|
||||||||||
Issue descriptionUserAgent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36 Steps to reproduce the problem: 1. Chrome Extension creates two popups. Default popup works fine to send a buffer to a server via XMLHttp. From first popup, open a 2nd popup. 2. When the 2nd popup sends a buffer to server via XMLHttp, two copies of the same buffer are sent. Each on a different contiguous port. 3. DevTools only reports a single buffer as being sent. What is the expected behavior? A single buffer should be sent from a single port. What went wrong? Tow copies of the same buffer appear at the server application instead of one. Did this work before? No Chrome version: 71.0.3578.98 Channel: stable OS Version: 6.1 (Windows 7, Windows Server 2008 R2) Flash Version: The attached files are 1) Wireshark packet capture showing dual buffers in packets 41 and 42. Packets 30 and 32 show the start of using two ports (49814 and 19815). 2) Screenshot of Devtools showing only a single packet as being sent.
,
Dec 26
,
Dec 26
Rafael, Here is the background task. Notice that there are a number of functions that send data to the host via XMLHttp? The two of most interest are the two at the bottom: send_to_logger and send_to_logger_survey. They are pretty much the same except the former works fine and the second one causes the doubling of the buffer. My Extension consists of two popups (I will attach the manifest with the key removed). Here is how it works: 1) popup.html is the default popup and uses popup.js 2) popup_survey.html is a second popup. The user can open this from a button on the default popup. 3) background.js is used by both popup.html and popup_survey.html. A user can press a button on popup.html and this (via onMessage) sends a message to background.js to call send_to_logger(). This works fine. The user can also press the Survey button on the default popup and this opens popup_survey.html. The user can now press a button on popup_survey.html. This causes popup_survey.js to send a message to background.js via the onMessage. Background sees this and runs send_to_logger_survey(). This sends a message correctly, but it causes two of the same message to be sent (see packets 26 and 27). Wireshark sees two buffers and also my server also sees two. Still, Devtools only sees one. I am attaching a bunch of things. 1. copy of background.js. The two functions at the bottom are the two where one works and the other doesn't. It almost sees that a message initiated from a child popup is the problem. Remember, all calls to XMLHttp are from the same background.js file. 2. a screenshot of devtools' network tab showing only a single buffer being sent. 3. a screenshot of Wireshark showing that two buffers are being sent. Notice that two contiguous ports on the chrome client are being used. Notice packet 26 and 27. This is where the "two ports" problem starts. 4. When I send the errant buffer, I stick a random number in the payload. I have noticed that although otherwise identical, the normal buffer and the reflected buffer have two different random numbers. I have set a breakpoint at the send() in send_to_logger_survey(), but only see it executing once. Let me know what else i can send you? I can recreate this error at will. I tried to send you the background.js but i get a message "blocked for security reasons". Can you tell me how I can get it to you?
,
Dec 26
Here is the send__to_logger_survey() from background.js
function send_to_logger_survey(request, sender, sendResponse)
{
var myArray=[];
var jsonResponse2;
var d=new Date();
myArray.push(email);
myArray.push(request.values); //contains chosen values
myArray.push(Math.random()); //push random number
console.log("sent to server\n");
var json = JSON.stringify(myArray);
var n = json.length; //this must be less than 1472 to avoid fragmentation
var url=szHost;
url=url.concat('/Subit_backend/logger_survey');
var xhr2 = new XMLHttpRequest();
xhr2.onerror = function() { alert('error'); };
xhr2.open('POST', url, true);
xhr2.setRequestHeader("Content-type", "application/json")
xhr2.setRequestHeader("X-Requested-With",'xmlhttprequest');
xhr2.setRequestHeader("Access-Control-Allow-Origin", "*");
xhr2.onload = function (){
if((xhr2.status === 200)&&(xhr2.readyState===4)) {
if (xhr2.responseText==="")
var jsonResponse2="empty";
else
var jsonResponse2 = JSON.parse(xhr2.responseText);
sendResponse({task: jsonResponse2});
return true; //The sendResponse callback is only valid if used
synchronously, or if the event handler returns true to indicate that it
will respond asynchronously.
}
};
xhr2.send(json);
}
,
Dec 26
Thank you for providing more feedback. Adding the requester to the cc list. For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
,
Dec 27
,
Jan 8
Can you provide a network dump generated by Chrome? https://dev.chromium.org/for-testers/providing-network-details
,
Jan 8
here it is
,
Jan 8
Thank you for providing more feedback. Adding the requester to the cc list. For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
,
Jan 9
No log is attached, probably because you attached it to an e-mail. Please use the web form.
,
Jan 9
OK. here it is again.
,
Jan 9
Thank you for providing more feedback. Adding the requester to the cc list. For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
,
Jan 9
Thanks. There are indeed two requests. One is ID: 272652 and the other is ID: 272658. Tow requests are different because the former request body length is 656 and the latter request body length is 655. So I think you are issuing two different requests to the same URL. You can check "Include raw bytes (will include cookies and credentials)" in chrome://net-export to see the request body. That log contains privacy sensitive information so it may be dangerous to share the log, but can you take a look by yourself?
,
Jan 9
(FYI: You can view the log by visiting https://netlog-viewer.appspot.com/#import).
,
Jan 9
That is the crux of the problem. If you review the capture2.jpg above you will see that develops only sees one request. In addition I have set a breakpoint on the send in question and it is only firing once. Here is a theory: since there are two pop ups that both communicate with the same background.js, is it possible that they are both calling background.js in rapid succession? If that was true wouldn't devtools show both Posts?
,
Jan 9
Thank you for providing more feedback. Adding the requester to the cc list. For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
,
Jan 9
here it is with the raw bytes setting. |
||||||||||
►
Sign in to add a comment |
||||||||||
Comment 1 by viswa.karala@chromium.org
, Dec 26Labels: Needs-Feedback Triaged-ET