From 2859def2b3b7b74ba061958daf437e7d5ea0446d Mon Sep 17 00:00:00 2001 From: Mihkel Sokk Date: Thu, 26 Jan 2017 11:34:33 +0200 Subject: [PATCH] Fix waitForText not found double callback error --- src/renderer.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/renderer.js b/src/renderer.js index 0275018..9538a2e 100644 --- a/src/renderer.js +++ b/src/renderer.js @@ -97,11 +97,12 @@ exports.renderWorker = function renderWorker(window, task, done) { webContents.on('found-in-page', function foundInPage(event, result) { if (result.matches === 0) { const isRetrying = waitOperation.retry(new Error('not ready to render')); - if (!isRetrying) done(new RendererError('TEXT_NOT_FOUND', `Failed to find text: ${task.waitForText}`, 404)); - return; - } - if (result.finalUpdate) { + if (!isRetrying) { + done(new RendererError('TEXT_NOT_FOUND', `Failed to find text: ${task.waitForText}`, 404)); + webContents.removeListener('found-in-page', foundInPage); + } + } else if (result.finalUpdate) { webContents.stopFindInPage('clearSelection'); webContents.removeListener('found-in-page', foundInPage); renderIt();