From ad9e64d086d8a5d12a046b6a38ed54d371068ee2 Mon Sep 17 00:00:00 2001 From: Samuel Attard Date: Tue, 17 Jul 2018 13:32:28 +1000 Subject: [PATCH] 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 --- lib/browser/api/web-contents.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/browser/api/web-contents.js b/lib/browser/api/web-contents.js index f5f53f44a312..4b3e777b4dcb 100644 --- a/lib/browser/api/web-contents.js +++ b/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) }) })