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(browser-runner): reject promise on error #7338
fix(browser-runner): reject promise on error #7338
Conversation
This patch adds a reject callback to the _processClosing promise and executes it if it catches an error on removeFolderAsync(...).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please
- add a test so that we don’t regress this behavior?
- update the documentation
@mathiasbynens for sure. I will add that as soon as I have some free time. What part specifically from the doc should I update? Thanks. |
|
I would really love to see this in the next version! |
Sorry for the delay. Been very busy (with a project using puppeteer hah). Will get on this this evening hopefully. |
Hi folks! Firstly, I added the required documentation in On the unit tests, after spending some hours, I think there's no practical way to unit test this without doing some other changes. Here's what happens: This can only be reproduced if for some reason the temp folder cannot be deleted (for example: a different process is blocking a file in it, the folder no longer exists or insufficient permissions). Knowing this, the only practical way I can think of is changing the value of the it('should reject promise on error with deleting temp folder', async () => {
const { puppeteer, defaultBrowserOptions } = getTestState();
const browser = await puppeteer.launch(defaultBrowserOptions); // the temp folder gets created
await browser.close(); // the temp folder gets removed and connection is disposed
let error = undefined;
try {
await browser.close(); // will attempt to delete non-existent temp folder
} catch (err) {
error = err
}
expect(error).toBeDefined();
}); but this wouldn't work either because the attempt to delete the folder occurs in a If you can think of a way to unit test this change or if you agree to make the value of |
This patch adds a reject callback to the _processClosing promise and executes it if it catches an error on removeFolderAsync(...). Co-authored-by: Mathias Bynens <mathias@qiwi.be>
I would like to report that, while this fix works (I prefer resolved vs rejected) and doesn't hang the browser, there is still a lot of instability caused by trying to remove the temporary directory. Our production service on Windows crashes ever so often due to that. Right now the way we patched this is to schedule ( |
This patch adds a reject callback to the _processClosing promise and executes it if it catches an error on removeFolderAsync(...).
Worth noting that I found this while experiencing this issue: original, fairly-recent duplicate.
This change DOES NOT attempt to fix the actual bug that prevents from removing CrashpadMetrics-active.pma temp file, but it solves the most annoying part which is letting the process hanging. This change should allow the client to catch the error in their own implementation and handle it adequately based on their needs.