Commit e11a3f65 authored by Nick Alexander's avatar Nick Alexander
Browse files

Bug 1782924 - Avoid crash writing Firefox Messaging System targeting...

Bug 1782924 - Avoid crash writing Firefox Messaging System targeting information at shutdown. r=application-update-reviewers,bytesized

I tested this as much as I could locally -- hence the `dump`
workaround -- but I have no particular suggestion for how to test this
in automation.  Even triggering the targeting snapshotting during
shutdown requires the timers and shutdown process to line up in a way
that's not trivial to guarantee.

Differential Revision: https://phabricator.services.mozilla.com/D154285
parent e45f347e
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -750,6 +750,10 @@ ConsoleAPI.prototype = {
  set maxLogLevel(aValue) {
    this._maxLogLevel = this._maxExplicitLogLevel = aValue;
  },

  shouldLog(aLevel) {
    return shouldLog(aLevel, this.maxLogLevel);
  },
};

var console = new ConsoleAPI();
+12 −0
Original line number Diff line number Diff line
@@ -629,6 +629,18 @@ var BackgroundUpdate = {

    let snapshot = new lazy.JSONFile({
      beforeSave: async () => {
        if (Services.startup.shuttingDown) {
          // Collecting targeting information can be slow and cause shutdown
          // crashes.  Just write what we have in that case.  During shutdown,
          // the regular log apparatus is not available, so use `dump`.
          if (lazy.log.shouldLog("debug")) {
            dump(
              `${SLUG}: shutting down, so not updating Firefox Messaging System targeting information\n`
            );
          }
          return;
        }

        lazy.log.debug(
          `${SLUG}: preparing to write Firefox Messaging System targeting information to ${path}`
        );