mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-02 07:05:24 +00:00
Bug 1189425 - Remove unparsable pings from the disk. r=vladan
This commit is contained in:
parent
182853ec0e
commit
d7b7df9ee3
@ -1257,12 +1257,14 @@ let TelemetryStorageImpl = {
|
||||
ping = yield this.loadPingFile(info.path, false);
|
||||
} catch(e) {
|
||||
// If we failed to load the ping, check what happened and update the histogram.
|
||||
// Then propagate the rejection.
|
||||
if (e instanceof PingReadError) {
|
||||
Telemetry.getHistogramById("TELEMETRY_PENDING_LOAD_FAILURE_READ").add();
|
||||
} else if (e instanceof PingParseError) {
|
||||
Telemetry.getHistogramById("TELEMETRY_PENDING_LOAD_FAILURE_PARSE").add();
|
||||
}
|
||||
// Remove the ping from the cache, so we don't try to load it again.
|
||||
this._pendingPings.delete(id);
|
||||
// Then propagate the rejection.
|
||||
throw e;
|
||||
};
|
||||
|
||||
@ -1442,8 +1444,9 @@ let TelemetryStorageImpl = {
|
||||
try {
|
||||
array = yield OS.File.read(aFilePath, options);
|
||||
} catch(e) {
|
||||
this._log.trace("loadPingfile - unreadable ping " + aFilePath, e);
|
||||
throw new PingReadError(e.message);
|
||||
};
|
||||
}
|
||||
|
||||
let decoder = new TextDecoder();
|
||||
let string = decoder.decode(array);
|
||||
@ -1455,6 +1458,10 @@ let TelemetryStorageImpl = {
|
||||
ping.payload = JSON.parse(ping.payload);
|
||||
}
|
||||
} catch (e) {
|
||||
this._log.trace("loadPingfile - unparseable ping " + aFilePath, e);
|
||||
yield OS.File.remove(aFilePath).catch((ex) => {
|
||||
this._log.error("loadPingFile - failed removing unparseable ping file", ex);
|
||||
});
|
||||
throw new PingParseError(e.message);
|
||||
}
|
||||
|
||||
|
@ -316,6 +316,9 @@ add_task(function* test_corrupted_pending_pings() {
|
||||
h = Telemetry.getHistogramById("TELEMETRY_PENDING_LOAD_FAILURE_PARSE").snapshot();
|
||||
Assert.equal(h.sum, 1, "Telemetry must report a pending ping parse failure");
|
||||
|
||||
let exists = yield OS.File.exists(getSavePathForPingId(pendingPingId));
|
||||
Assert.ok(!exists, "The unparseable ping should have been removed");
|
||||
|
||||
yield clearPendingPings();
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user