fix(Page): remove event listeners to avoid MaxListenersExceededWarning

This patch starts to properly clean up event listeners on a failed navigation (Page.goto).
This commit is contained in:
mizdra
2017-09-30 16:50:13 +09:00
committed by Andrey Lushnikov
parent 53531c9a92
commit 215b3497c7
2 changed files with 10 additions and 0 deletions

View File

@@ -384,6 +384,7 @@ class Page extends EventEmitter {
await this._client.send('Page.navigate', {url, referrer});
} catch (e) {
watcher.cancel();
helper.removeEventListeners([listener]);
throw e;
}
const error = await navigationPromise;