Bug 1505045 - Fix error in setTimeoutIfNeeded when store is not ready yet; r=Honza.
authorNicolas Chevobbe <nchevobbe@mozilla.com>
Mon, 12 Nov 2018 15:09:45 +0000
changeset 445887 b05772bcb6f4e6e7e83cb7e05d12d160f82f65b5
parent 445886 96046dff0022da18603a359733514a4ff0efc799
child 445888 577c34da7b73f1d33026ff0c768ace3e893c34b8
push id35028
push usercsabou@mozilla.com
push dateMon, 12 Nov 2018 21:54:15 +0000
treeherdermozilla-central@05331fb8f533 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersHonza
bugs1505045
milestone65.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1505045 - Fix error in setTimeoutIfNeeded when store is not ready yet; r=Honza. In some cases, the setTimeoutIfNeeded function can be called before the store is initialized, which is causing an exception when we try to dispatch the messages. With this patch, we check if the store is not ready, and re-schedule a timeout so messages can be handled properly when the store is ready. Differential Revision: https://phabricator.services.mozilla.com/D11044
devtools/client/webconsole/webconsole-output-wrapper.js
--- a/devtools/client/webconsole/webconsole-output-wrapper.js
+++ b/devtools/client/webconsole/webconsole-output-wrapper.js
@@ -444,16 +444,23 @@ WebConsoleOutputWrapper.prototype = {
     if (this.throttledDispatchPromise) {
       return;
     }
 
     this.throttledDispatchPromise = new Promise(done => {
       setTimeout(() => {
         this.throttledDispatchPromise = null;
 
+        if (!store) {
+          // The store is not initialized yet, we can call setTimeoutIfNeeded so the
+          // messages will be handled in the next timeout when the store is ready.
+          this.setTimeoutIfNeeded();
+          return;
+        }
+
         store.dispatch(actions.messagesAdd(this.queuedMessageAdds));
 
         const length = this.queuedMessageAdds.length;
 
         // This telemetry event is only useful when we have a toolbox so only
         // send it when we have one.
         if (this.toolbox) {
           this.telemetry.addEventProperty(