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: Wait for child process to be ready #19792

Merged
merged 8 commits into from
Feb 17, 2022
2 changes: 2 additions & 0 deletions packages/server/lib/plugins/child/run_plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,8 @@ const runPlugins = (ipc, pluginsFile, projectRoot) => {
ipc.on('execute', (event, ids, args) => {
execute(ipc, event, ids, args)
})

ipc.send('ready')
}

// for testing purposes
Expand Down
4 changes: 3 additions & 1 deletion packages/server/lib/plugins/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,9 @@ const init = (config, options) => {
Object.keys(config).sort().forEach((key) => orderedConfig[key] = config[key])
config = orderedConfig

ipc.send('load', config)
ipc.on('ready', () => {
ipc.send('load', config)
})

ipc.on('loaded', (newCfg, registrations) => {
_.omit(config, 'projectRoot', 'configFile')
Expand Down
3 changes: 2 additions & 1 deletion packages/server/test/unit/plugins/index_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ describe('lib/plugins/index', () => {
})
})

it('sends \'load\' event with config via ipc', () => {
it('sends \'load\' event with config via ipc once it receives \'ready\'', () => {
ipc.on.withArgs('ready').yields([])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test seems to pass without the changes in this PR. Can you add a test that demonstrates the failing case fixed by this PR (asynchronous plugin registration)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right. I'll try to fix that in the next couple of days.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated the test. Ready to be reviewed again :)

ipc.on.withArgs('loaded').yields([])
const config = { pluginsFile: 'cypress-plugin', testingType: 'e2e' }

Expand Down