Skip to content

Commit 56db624

Browse files
author
Daniel Herzog
committed
Fix for DFL-3324: An item with "Sequence terminated, retry" has two entries in the detail view
1 parent a6280d4 commit 56db624

File tree

2 files changed

+55
-16
lines changed

2 files changed

+55
-16
lines changed

src/network/network_details_templates.js

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ templates.details = function(entry, left_val, do_raw)
5252

5353
templates._details_content = function(entry, do_raw)
5454
{
55-
var responsecode = entry.current_responsecode;
55+
var responsecode = entry.last_responsecode;
5656
if (responsecode && responsecode in cls.ResourceUtil.http_status_codes)
5757
responsecode = responsecode + " " + cls.ResourceUtil.http_status_codes[responsecode];
5858

@@ -83,7 +83,7 @@ templates._details_content = function(entry, do_raw)
8383
["td",
8484
entry.touched_network && responsecode ? String(responsecode) : ui_strings.S_RESOURCE_ALL_NOT_APPLICABLE
8585
],
86-
"data-spec", "http#" + entry.current_responsecode
86+
"data-spec", "http#" + entry.last_responsecode
8787
]
8888
],
8989
entry.touched_network ? [] : this.did_not_touch_network(entry),
@@ -105,23 +105,48 @@ templates.did_not_touch_network = function(entry)
105105

106106
templates.requests_responses = function(do_raw, request_response, index, requests_responses)
107107
{
108-
var is_last = index == requests_responses.length - 1;
109-
var template_func = this._response;
108+
var is_last_of_type = true;
109+
var template_func;
110+
111+
// todo: ugly.
110112
if (request_response instanceof cls.NetworkLoggerRequest)
113+
{
114+
for (var i = index + 1, req_res; req_res = requests_responses[i]; i++)
115+
if (req_res instanceof cls.NetworkLoggerRequest)
116+
is_last_of_type = false;
117+
111118
template_func = this._request;
119+
}
120+
else
121+
{
122+
for (var i = index + 1, req_res; req_res = requests_responses[i]; i++)
123+
if (req_res instanceof cls.NetworkLoggerResponse)
124+
is_last_of_type = false;
125+
126+
template_func = this._response;
127+
}
112128

113-
return template_func.call(this, request_response, is_last, do_raw);
129+
return template_func.call(this, request_response, is_last_of_type, do_raw);
114130
};
115131

116-
templates._request = function(request, is_last, do_raw)
132+
templates._request = function(request, is_last_request, do_raw)
117133
{
134+
// A request that's followed by another one, without a response in between,
135+
// is not shown in network-details. It will mostly mean it was retried internally
136+
// and didn't go on the network.
137+
// That can't be determined only by looking at RequestRetry events, because a
138+
// request with for example a 401 Authorization Required response should still
139+
// be shown.
140+
if (!is_last_request && !request.was_responded)
141+
return [];
142+
118143
return [
119144
templates._request_headers(request, do_raw),
120145
templates._request_body(request, do_raw)
121146
]
122147
};
123148

124-
templates._response = function(response, is_last, do_raw)
149+
templates._response = function(response, is_last, do_raw) // todo: is_last_response?
125150
{
126151
return [
127152
this._response_headers(response, do_raw),

src/network/network_service.js

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ cls.RequestContextPrototype = function()
405405
the last entry we saw with the event's resourceID.
406406
*/
407407
return event.requestID &&
408-
(last_entry.requestID !== event.requestID);
408+
(last_entry.last_requestID !== event.requestID);
409409
};
410410

411411
this.update = function(eventname, event)
@@ -429,7 +429,7 @@ cls.RequestContextPrototype = function()
429429
else
430430
{
431431
var logger_entry = logger_entries.last;
432-
if (logger_entry && logger_entry.requestID)
432+
if (logger_entry && logger_entry.last_requestID)
433433
{
434434
/*
435435
The same resource id can be loaded several times, but then the request id changes.
@@ -443,7 +443,7 @@ cls.RequestContextPrototype = function()
443443
{
444444
opera.postError(ui_strings.S_DRAGONFLY_INFO_MESSAGE +
445445
" Unexpected change in requestID on " + eventname +
446-
": Change from " + logger_entry.requestID + " to " +
446+
": Change from " + logger_entry.last_requestID + " to " +
447447
event.requestID + ", URL: " + logger_entry.human_url);
448448
}
449449
}
@@ -454,7 +454,7 @@ cls.RequestContextPrototype = function()
454454
logger_entry = new cls.NetworkLoggerEntry(id, event.resourceID, event.documentID, this.get_starttime());
455455
this._logger_entries.push(logger_entry);
456456
}
457-
logger_entry.requestID = event.requestID;
457+
logger_entry.last_requestID = event.requestID;
458458
logger_entry.update(eventname, event);
459459
}
460460

@@ -503,7 +503,7 @@ cls.NetworkLoggerEntry = function(id, resource_id, document_id, context_starttim
503503
this.starttime_relative = null;
504504
this.endtime = null;
505505
this.requests_responses = [];
506-
this.current_responsecode = null;
506+
this.last_responsecode = null;
507507
this.last_method = null;
508508
this.is_unloaded = false;
509509
this.is_finished = false;
@@ -756,13 +756,19 @@ cls.NetworkLoggerEntryPrototype = function()
756756

757757
this._update_event_requestretry = function(event)
758758
{
759-
this.requestID = event.toRequestID;
759+
// This means on the next request with event.toRequestID, we won't
760+
// make a new entry, but a new NetworkLoggerRequest on the same entry.
761+
this.last_requestID = event.toRequestID;
760762
};
761763

762764
this._update_event_response = function(event)
763765
{
764-
this.current_responsecode = event.responseCode;
765-
this.error_in_current_response = /^[45]/.test(this.current_responsecode);
766+
if (this._current_request)
767+
{
768+
this._current_request.was_responded = true;
769+
}
770+
this.last_responsecode = event.responseCode;
771+
this.error_in_last_response = /^[45]/.test(this.last_responsecode);
766772
this._current_response = new cls.NetworkLoggerResponse(this);
767773
this.requests_responses.push(this._current_response);
768774
this._current_response._update_event_response(event);
@@ -774,6 +780,10 @@ cls.NetworkLoggerEntryPrototype = function()
774780
// therefore have to init NetworkLoggerResponse here. See CORE-43935.
775781
if (!this._current_response)
776782
{
783+
if (this._current_request)
784+
{
785+
this._current_request.was_responded = true;
786+
}
777787
this._current_response = new cls.NetworkLoggerResponse(this);
778788
this.requests_responses.push(this._current_response);
779789
}
@@ -918,7 +928,11 @@ cls.NetworkLoggerRequest = function(entry)
918928
this.firstline = null;
919929
this.requestbody = null;
920930
this.boundary = "";
921-
this.header_tokens = null; // This is set from template code, when it's first needed.
931+
this.was_responded = false;
932+
// Set from template code, when first needed:
933+
this.header_tokens = null;
934+
// Belongs here, unused though:
935+
this.requestID = entry.requestID;
922936
};
923937

924938
cls.NetworkLoggerRequestPrototype = function()

0 commit comments

Comments
 (0)