Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preload scripts can run twice in the same process in different node environments #17576

Closed
MarshallOfSound opened this issue Mar 27, 2019 · 2 comments · Fixed by #18860
Closed
Assignees
Labels
3-1-x 4-2-x 5-0-x bug 🪲 bug/regression ↩️ A new version of Electron broke something status/confirmed A maintainer reproduced the bug or agreed with the feature
Projects

Comments

@MarshallOfSound
Copy link
Member

Issue Details

  • Electron Version:
    • 3.x, 4.x, 5.x, 6.x
  • Operating System:
    • All
  • Last Known Working Electron version::
    • 2.x

Expected Behavior

When navigations occur, a new process should be created for the navigation.

Actual Behavior

When a navigation occurs during a preloads scripts execution the same process is re-used as Chromium does not think the navigation has been committed yet. This causes a memory leak and all native node modules to break.

To Reproduce

Fiddle: https://gist.github.com/MarshallOfSound/c89aa0037c3da114d44aa3a2d1a0fc24

Screenshots

image

As you can see here there are three navigation loads, the second and the third one actually have the same process ID (and are running in the same process)

@MarshallOfSound MarshallOfSound self-assigned this Mar 27, 2019
@MarshallOfSound MarshallOfSound added bug 🪲 bug/regression ↩️ A new version of Electron broke something status/confirmed A maintainer reproduced the bug or agreed with the feature component/plznavigate 4-2-x 5-0-x 3-1-x labels Mar 27, 2019
MarshallOfSound added a commit that referenced this issue Mar 27, 2019
navigations

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
trop-bot pushed a commit to trop-bot/electron that referenced this issue Mar 27, 2019
…vigations

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 electron#17576
trop-bot pushed a commit to trop-bot/electron that referenced this issue Mar 27, 2019
…vigations

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 electron#17576
trop-bot pushed a commit to trop-bot/electron that referenced this issue Mar 27, 2019
…vigations

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 electron#17576
@sofianguy sofianguy added this to Unsorted Issues in 5.0.x Mar 27, 2019
@sofianguy sofianguy moved this from Unsorted Issues to Doesn't Block Stable in 5.0.x Mar 28, 2019
trop-bot pushed a commit to trop-bot/electron that referenced this issue Mar 28, 2019
…vigations

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 electron#17576
trop-bot pushed a commit to trop-bot/electron that referenced this issue Mar 28, 2019
…vigations

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 electron#17576
trop-bot pushed a commit to trop-bot/electron that referenced this issue Mar 28, 2019
…vigations

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 electron#17576
MarshallOfSound pushed a commit that referenced this issue Mar 28, 2019
…vigations (#17595)

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
MarshallOfSound pushed a commit that referenced this issue Mar 28, 2019
…vigations (#17596)

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
MarshallOfSound pushed a commit that referenced this issue Mar 28, 2019
…vigations (#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
@miniak
Copy link
Contributor

miniak commented May 7, 2019

@MarshallOfSound can you share more details? Why wasn't this an issue in Electron 2?

kiku-jw pushed a commit to kiku-jw/electron that referenced this issue May 16, 2019
…lectron#17577)

navigations

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 electron#17576
@MarshallOfSound
Copy link
Member Author

Merging into #18397 as the long term solution to this 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3-1-x 4-2-x 5-0-x bug 🪲 bug/regression ↩️ A new version of Electron broke something status/confirmed A maintainer reproduced the bug or agreed with the feature
Projects
No open projects
5.0.x
Doesn't Block Stable
Development

Successfully merging a pull request may close this issue.

2 participants