Skip to content

feat(core): add config to skip waiting for browser close#120

Closed
doteric wants to merge 1 commit intofacebook:mainfrom
doteric:feat/no_wait_browser_close
Closed

feat(core): add config to skip waiting for browser close#120
doteric wants to merge 1 commit intofacebook:mainfrom
doteric:feat/no_wait_browser_close

Conversation

@doteric
Copy link

@doteric doteric commented May 22, 2024

Issue: #95

@facebook-github-bot
Copy link
Contributor

Hi @doteric!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@doteric doteric force-pushed the feat/no_wait_browser_close branch 2 times, most recently from 283fa8a to 3d49eb4 Compare May 22, 2024 09:15
@doteric doteric force-pushed the feat/no_wait_browser_close branch from 3d49eb4 to 1e17020 Compare May 22, 2024 09:17
await Promise.all(pages.map(page => page.close()));
await browser.disconnect();
} else if (config.skipBrowserCloseWait === true) {
browser.close();
Copy link
Member

Choose a reason for hiding this comment

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

In this case, skipping waiting for the promising to resolve may allow memlab to proceed, but after memory leak detection is done, the JS runtime would still not able to terminate since it would wait for all promises to resolve. Do you force terminate the node.js runtime somehow in the end?

Copy link
Author

Choose a reason for hiding this comment

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

Thanks for the question!
We use Memlab inside AWS Lambdas where we do not have to wait for the runtime to finish. It keeps running and in the meantime if the browser finally closes then good, if not then AWS Lambda will terminate the runtime anyway. Ideally, of course, would be the browser.close() to not hang and just close the browser properly, but it's not so straightforward why the closing hangs, it would require deeper investigation.

In some cases iterating through all the opened pages and closing them before closing the browser worked, but in case of Memlab this does not seem to work correctly as the browser instance seems to return no opened pages.
Sparticuz/chromium#85 (comment)

Please let me know if I explained this fine or would you want further clarification. Happy to discuss further if needed

Copy link
Member

@JacksonGL JacksonGL May 24, 2024

Choose a reason for hiding this comment

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

@doteric That makes sense. Thanks for the context. Please check and accept the CLA agreement so I can import and integrate your change.

https://github.com/facebook/memlab/blob/main/CONTRIBUTING.md#contributor-license-agreement-cla

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label May 25, 2024
@facebook-github-bot
Copy link
Contributor

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@facebook-github-bot
Copy link
Contributor

@JacksonGL has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@JacksonGL merged this pull request in 3024612.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants