Don't remove any scrollback when job has fatal exception

This commit is contained in:
Ivan Kozik 2015-03-27 12:48:42 +00:00
parent 07a23d2a98
commit 486453d63b

View File

@ -535,6 +535,7 @@ var JobsTracker = function() {
this.sorted = []; this.sorted = [];
this.finishedArray = []; this.finishedArray = [];
this.finishedSet = {}; this.finishedSet = {};
this.fatalExceptionSet = {};
}; };
JobsTracker.prototype.countActive = function() { JobsTracker.prototype.countActive = function() {
@ -559,20 +560,30 @@ JobsTracker.prototype.handleJobData = function(jobData) {
return !alreadyKnown; return !alreadyKnown;
}; };
JobsTracker.prototype.markFinished = function(jobData) { JobsTracker.prototype.markFinished = function(ident) {
var ident = jobData["ident"];
if(!(ident in this.finishedSet)) { if(!(ident in this.finishedSet)) {
this.finishedSet[ident] = true; this.finishedSet[ident] = true;
this.finishedArray.push(ident); this.finishedArray.push(ident);
} }
}; };
JobsTracker.prototype.markUnfinished = function(jobData) { JobsTracker.prototype.markUnfinished = function(ident) {
var ident = jobData["ident"];
if(ident in this.finishedSet) { if(ident in this.finishedSet) {
delete this.finishedSet[ident]; delete this.finishedSet[ident];
removeFromArray(this.finishedArray, ident); removeFromArray(this.finishedArray, ident);
} }
// Job was restarted, so unmark fatal exception
if(ident in this.fatalExceptionSet) {
delete this.fatalExceptionSet[ident];
}
};
JobsTracker.prototype.markFatalException = function(ident) {
this.fatalExceptionSet[ident] = true;
};
JobsTracker.prototype.hasFatalException = function(ident) {
return ident in this.fatalExceptionSet;
}; };
@ -851,6 +862,7 @@ JobsRenderer.prototype._renderStdoutLine = function(data, logSegment, info, iden
this.jobs.markFinished(ident); this.jobs.markFinished(ident);
} else if(/^ERROR Fatal exception/.test(line)) { } else if(/^ERROR Fatal exception/.test(line)) {
info.statsElements.jobInfo.classList.add('job-info-fatal'); info.statsElements.jobInfo.classList.add('job-info-fatal');
this.jobs.markFatalException(ident);
} else if(/Script requested immediate stop/.test(line)) { } else if(/Script requested immediate stop/.test(line)) {
// Note: above message can be in: // Note: above message can be in:
// ERROR Script requested immediate stop // ERROR Script requested immediate stop
@ -957,17 +969,21 @@ JobsRenderer.prototype.handleData = function(data) {
} }
if(this.mouseInside != ident) { if(this.mouseInside != ident) {
// We may have to remove more than one segment, if the user // Don't remove any scrollback information when the job has a fatal exception,
// has paused the log window for a while. // so that the user can find the traceback and report a bug.
while(info.lineCountWindow >= this.historyLines + this.linesPerSegment) { if(!this.jobs.hasFatalException(ident)) {
var firstLogSegment = info.logWindow.firstChild; // We may have to remove more than one segment, if the user
assert(firstLogSegment != null, "info.logWindow.firstChild is null; " + // has paused the log window for a while.
JSON.stringify({ while(info.lineCountWindow >= this.historyLines + this.linesPerSegment) {
"lineCountWindow": info.lineCountWindow, var firstLogSegment = info.logWindow.firstChild;
"lineCountSegments": info.lineCountSegments})); assert(firstLogSegment != null, "info.logWindow.firstChild is null; " +
info.logWindow.removeChild(firstLogSegment); JSON.stringify({
info.lineCountWindow -= info.lineCountSegments[0]; "lineCountWindow": info.lineCountWindow,
info.lineCountSegments.shift(); "lineCountSegments": info.lineCountSegments}));
info.logWindow.removeChild(firstLogSegment);
info.lineCountWindow -= info.lineCountSegments[0];
info.lineCountSegments.shift();
}
} }
// Scroll to the bottom // Scroll to the bottom