From 9e12e8c63f22dba898e2cf628b877b1ccf4f5a9c Mon Sep 17 00:00:00 2001 From: "trop[bot]" Date: Thu, 28 Mar 2019 12:56:29 -0700 Subject: [PATCH] fix: handle a race condition between preload scripts executing and navigations (#17597) There is a race condition between DidCreateScriptContext and another navigation occuring in the main process. If the navigation occurs while the preload script is running, the same process is re-used. This ensures that any pending navigations are completely removed / ignored when we trigger a new navigation. Fixes #17576 --- atom/browser/api/atom_api_web_contents.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/atom/browser/api/atom_api_web_contents.cc b/atom/browser/api/atom_api_web_contents.cc index bc8b2f13ced49..51ae43645dfbc 100644 --- a/atom/browser/api/atom_api_web_contents.cc +++ b/atom/browser/api/atom_api_web_contents.cc @@ -1214,6 +1214,9 @@ void WebContents::LoadURL(const GURL& url, const mate::Dictionary& options) { params.transition_type = ui::PAGE_TRANSITION_TYPED; params.should_clear_history_list = true; params.override_user_agent = content::NavigationController::UA_OVERRIDE_TRUE; + // Discord non-committed entries to ensure that we don't re-use a pending + // entry + web_contents()->GetController().DiscardNonCommittedEntries(); web_contents()->GetController().LoadURLWithParams(params); // Set the background color of RenderWidgetHostView.