Bug 1929109 - Better handle I/O issues that may be triggered while recording crashes r=afranchuk
Differential Revision: https://phabricator.services.mozilla.com/D229501
This commit is contained in:
@@ -46,10 +46,13 @@ export var makeFakeAppDir = function () {
|
|||||||
pendingD.append("pending");
|
pendingD.append("pending");
|
||||||
let submittedD = reportsD.clone();
|
let submittedD = reportsD.clone();
|
||||||
submittedD.append("submitted");
|
submittedD.append("submitted");
|
||||||
|
let eventsD = reportsD.clone();
|
||||||
|
eventsD.append("events");
|
||||||
|
|
||||||
makeDir(reportsD);
|
makeDir(reportsD);
|
||||||
makeDir(pendingD);
|
makeDir(pendingD);
|
||||||
makeDir(submittedD);
|
makeDir(submittedD);
|
||||||
|
makeDir(eventsD);
|
||||||
|
|
||||||
let provider = {
|
let provider = {
|
||||||
getFile(prop, persistent) {
|
getFile(prop, persistent) {
|
||||||
@@ -58,7 +61,10 @@ export var makeFakeAppDir = function () {
|
|||||||
return appD.clone();
|
return appD.clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
throw Components.Exception("", Cr.NS_ERROR_FAILURE);
|
throw Components.Exception(
|
||||||
|
"failed to get file: " + prop,
|
||||||
|
Cr.NS_ERROR_FAILURE
|
||||||
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
QueryInterace(iid) {
|
QueryInterace(iid) {
|
||||||
|
|||||||
@@ -784,7 +784,7 @@ CrashManager.prototype = Object.freeze({
|
|||||||
* Submit a Glean crash ping with the given parameters.
|
* Submit a Glean crash ping with the given parameters.
|
||||||
*
|
*
|
||||||
* @param {string} reason - the reason for the crash ping, one of: "crash", "event_found"
|
* @param {string} reason - the reason for the crash ping, one of: "crash", "event_found"
|
||||||
* @param {string} type - the process type (from {@link processTypes})
|
* @param {string} process_type - the process type (from {@link processTypes})
|
||||||
* @param {DateTime} date - the time of the crash (or the closest time after it)
|
* @param {DateTime} date - the time of the crash (or the closest time after it)
|
||||||
* @param {string} minidumpHash - the hash of the minidump file, if any
|
* @param {string} minidumpHash - the hash of the minidump file, if any
|
||||||
* @param {object} stackTraces - the object containing stack trace information
|
* @param {object} stackTraces - the object containing stack trace information
|
||||||
@@ -792,7 +792,7 @@ CrashManager.prototype = Object.freeze({
|
|||||||
*/
|
*/
|
||||||
_submitGleanCrashPing(
|
_submitGleanCrashPing(
|
||||||
reason,
|
reason,
|
||||||
type,
|
process_type,
|
||||||
date,
|
date,
|
||||||
minidumpHash,
|
minidumpHash,
|
||||||
stackTraces,
|
stackTraces,
|
||||||
@@ -810,7 +810,7 @@ CrashManager.prototype = Object.freeze({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Glean.crash.processType.set(type);
|
Glean.crash.processType.set(process_type);
|
||||||
Glean.crash.time.set(date.getTime() * 1000);
|
Glean.crash.time.set(date.getTime() * 1000);
|
||||||
Glean.crash.minidumpSha256Hash.set(minidumpHash);
|
Glean.crash.minidumpSha256Hash.set(minidumpHash);
|
||||||
|
|
||||||
@@ -1098,9 +1098,11 @@ CrashManager.prototype = Object.freeze({
|
|||||||
*/
|
*/
|
||||||
_getDirectoryEntries(path, re) {
|
_getDirectoryEntries(path, re) {
|
||||||
return (async function () {
|
return (async function () {
|
||||||
let children = await IOUtils.getChildren(path);
|
|
||||||
let entries = [];
|
let entries = [];
|
||||||
|
|
||||||
|
try {
|
||||||
|
let children = await IOUtils.getChildren(path);
|
||||||
|
|
||||||
for (const entry of children) {
|
for (const entry of children) {
|
||||||
let stat = await IOUtils.stat(entry);
|
let stat = await IOUtils.stat(entry);
|
||||||
if (stat.type == "directory") {
|
if (stat.type == "directory") {
|
||||||
@@ -1122,6 +1124,10 @@ CrashManager.prototype = Object.freeze({
|
|||||||
entries.sort((a, b) => {
|
entries.sort((a, b) => {
|
||||||
return a.date - b.date;
|
return a.date - b.date;
|
||||||
});
|
});
|
||||||
|
} catch (ex) {
|
||||||
|
// Missing events folders are allowed
|
||||||
|
console.error(ex);
|
||||||
|
}
|
||||||
|
|
||||||
return entries;
|
return entries;
|
||||||
})();
|
})();
|
||||||
@@ -1429,6 +1435,7 @@ CrashStore.prototype = Object.freeze({
|
|||||||
|
|
||||||
let encoder = new TextEncoder();
|
let encoder = new TextEncoder();
|
||||||
let data = encoder.encode(JSON.stringify(normalized));
|
let data = encoder.encode(JSON.stringify(normalized));
|
||||||
|
try {
|
||||||
let size = await IOUtils.write(this._storePath, data, {
|
let size = await IOUtils.write(this._storePath, data, {
|
||||||
tmpPath: this._storePath + ".tmp",
|
tmpPath: this._storePath + ".tmp",
|
||||||
compress: true,
|
compress: true,
|
||||||
@@ -1436,6 +1443,10 @@ CrashStore.prototype = Object.freeze({
|
|||||||
if (this._telemetrySizeKey) {
|
if (this._telemetrySizeKey) {
|
||||||
Services.telemetry.getHistogramById(this._telemetrySizeKey).add(size);
|
Services.telemetry.getHistogramById(this._telemetrySizeKey).add(size);
|
||||||
}
|
}
|
||||||
|
} catch (ex) {
|
||||||
|
// This operation might fail during shutdown, tough luck.
|
||||||
|
console.error(ex);
|
||||||
|
}
|
||||||
})();
|
})();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user