Browse Source

fix: race-condition in electron.net (#27898)

Emil Pettersson 4 years ago
parent
commit
a9b25dda85
1 changed files with 5 additions and 2 deletions
  1. 5 2
      lib/browser/api/net.ts

+ 5 - 2
lib/browser/api/net.ts

@@ -119,10 +119,13 @@ class IncomingMessage extends Readable {
       this._shouldPush = this.push(chunk);
     }
     if (this._shouldPush && this._resume) {
-      this._resume();
       // Reset the callback, so that a new one is used for each
-      // batch of throttled data
+      // batch of throttled data. Do this before calling resume to avoid a
+      // potential race-condition
+      const resume = this._resume;
       this._resume = null;
+
+      resume();
     }
   }