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

Workbench: cleanup the process shutdown routines #1364

Merged
merged 5 commits into from
Aug 10, 2023

Conversation

davemfish
Copy link
Contributor

@davemfish davemfish commented Aug 7, 2023

There was a race condition in the shutdown routine of the workbench. It would mainly come up during the Windows puppeteer test, where the python subprocess would not be given a chance to exit before electron & jest exited. Using execSync instead of exec to call taskkill seems reliable.

Fixed #1356 by removing the potential for an infinite loop while shutting down the python process. Polling the server to see if it was still live was actually papering over the real problem of the race condition mentioned above.

Fixes #1362 by making sure to close instances of pptr pages before trying to close the browser.

Unrelated to that, tests were sometimes unreliable because the script was trying to click on buttons before their click handlers were ready. I added some pauses in the execution to accommodate that and things appear reliable now.

Checklist

  • Updated HISTORY.rst and link to any relevant issue (if these changes are user-facing)
  • Updated the user's guide (if needed)
  • Tested the affected models' UIs (if relevant)

@davemfish davemfish requested a review from dcdenu4 August 7, 2023 15:51
@davemfish davemfish self-assigned this Aug 7, 2023
Copy link
Member

@dcdenu4 dcdenu4 left a comment

Choose a reason for hiding this comment

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

Thanks as always @davemfish for iterating and making the Workbench more stable. Just had a minor comment.

@@ -133,13 +133,15 @@ beforeEach(() => {

afterEach(async () => {
try {
const pages = await BROWSER.pages();
await Promise.all(pages.map(page => page.close()));
Copy link
Member

Choose a reason for hiding this comment

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

Nice.

@@ -232,11 +235,13 @@ test('Check local userguide links', async () => {
const downloadModal = await page.waitForSelector('.modal-dialog');
const downloadModalCancel = await downloadModal.waitForSelector(
'aria/[name="Cancel"][role="button"]');
await page.waitForTimeout(500); // waiting for click handler to be ready
Copy link
Member

Choose a reason for hiding this comment

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

Any reason this one is longer than the others? I don't think it's necessary if different click events could need different wait times but would it be convenient to have a constant variable defining these wait values?

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 don't know why it's different so I've made it the same, and I added a variable.

But it's likely each button is different, in terms of when it becomes functional. It seems dependent on whether the javascript containing the click handler's function has loaded yet, or whether the element is visible yet, or otherwise visually blocked somehow. All we know for sure is that the element is present in the DOM (that's what the waitForSelector accomplishes). But these other things remain unknown.

@davemfish davemfish requested a review from dcdenu4 August 10, 2023 15:39
@dcdenu4 dcdenu4 merged commit e395df2 into natcap:main Aug 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants