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

fix: uv loop polling when render process reuse enabled #25922

Merged
merged 1 commit into from Oct 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions shell/renderer/electron_renderer_client.cc
Expand Up @@ -108,12 +108,12 @@ void ElectronRendererClient::DidCreateScriptContext(

injected_frames_.insert(render_frame);

// If this is the first environment we are creating, prepare the node
// bindings.
if (!node_integration_initialized_) {
node_integration_initialized_ = true;
node_bindings_->Initialize();
node_bindings_->PrepareMessageLoop();
} else if (reuse_renderer_processes_enabled) {
node_bindings_->PrepareMessageLoop();
}

// Setup node tracing controller.
Expand All @@ -129,7 +129,7 @@ void ElectronRendererClient::DidCreateScriptContext(

// If we have disabled the site instance overrides we should prevent loading
// any non-context aware native module
if (command_line->HasSwitch(switches::kDisableElectronSiteInstanceOverrides))
if (reuse_renderer_processes_enabled)
env->ForceOnlyContextAwareNativeModules();
env->WarnNonContextAwareNativeModules();

Expand Down
24 changes: 24 additions & 0 deletions spec-main/api-browser-window-spec.ts
Expand Up @@ -4262,6 +4262,30 @@ describe('BrowserWindow module', () => {
});
});

describe('reloading with allowRendererProcessReuse enabled', () => {
it('does not cause Node.js module API hangs after reload', (done) => {
const w = new BrowserWindow({
show: false,
webPreferences: {
nodeIntegration: true
}
});

let count = 0;
ipcMain.on('async-node-api-done', () => {
if (count === 3) {
ipcMain.removeAllListeners('async-node-api-done');
done();
} else {
count++;
w.reload();
}
});

w.loadFile(path.join(fixtures, 'pages', 'send-after-node.html'));
});
});

describe('window.webContents.focus()', () => {
afterEach(closeAllWindows);
it('focuses window', async () => {
Expand Down