Browse Source

fix: remove race condition for executeJavaScript (#13691)

Replaces 'did-finish-load' with 'did-stop-loading' which semantically
maps to the events inside Chromium.  Before I think we were relying
on a natural 99% winnable race condition.

Fixes #13504
Samuel Attard 6 years ago
parent
commit
ad9e64d086
1 changed files with 1 additions and 1 deletions
  1. 1 1
      lib/browser/api/web-contents.js

+ 1 - 1
lib/browser/api/web-contents.js

@@ -184,7 +184,7 @@ WebContents.prototype.executeJavaScript = function (code, hasUserGesture, callba
     return asyncWebFrameMethods.call(this, requestId, 'executeJavaScript', callback, code, hasUserGesture)
   } else {
     return new Promise((resolve, reject) => {
-      this.once('did-finish-load', () => {
+      this.once('did-stop-loading', () => {
         asyncWebFrameMethods.call(this, requestId, 'executeJavaScript', callback, code, hasUserGesture).then(resolve).catch(reject)
       })
     })