-
Notifications
You must be signed in to change notification settings - Fork 14
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: preserve cache by using credentialless proxy #72
Conversation
return [ | ||
undefined, | ||
// eslint-disable-next-line @typescript-eslint/no-empty-function | ||
async () => {}, |
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.
The empty functions are still returned in order to prevent repeating if
s like
if (close) {
await close();
}
page.once('close', async () => { | ||
this.activePages--; | ||
|
||
await close(); |
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.
This is quite unsafe because the page may open popups and get closed after opening them.
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.
plus this can crash the entire process if close()
throws for some unforeseeable reason
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.
plus this can crash the entire process if
close()
throws for some unforeseeable reason
Yes, that's what we want. If it failed to close the server (which should never happen) then it leaks resources which means we want to crash.
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.
This is quite unsafe because the page may open popups and get closed after opening them.
Yeah, I see. But at the same time, closing those extra pages as well might be unexpected for users. Let's live with it and see if it causes any problems. The browsers have a hard kill interval anyway.
} catch (error: any) { | ||
log.exception(error, 'Failed to close context.'); | ||
} finally { | ||
await close(); |
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.
@@ -193,9 +193,6 @@ describe('Plugins', () => { | |||
}); | |||
|
|||
browser = await plugin.launch(context); | |||
const argWithProxy = context.launchOptions?.args?.find((arg) => arg.includes('--proxy-server=')); |
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.
These expectations have been removed because we check the end IP anyway. It should not check whether it goes through a local proxy server or not. Cache checks should be separate ones.
looks like the tests got stuck |
@B4nan Jest fails to properly detect open handles (this is one of the reasons I believe we shouldn't use Jest), it hangs indefinitely and reports unreffed (!) servers. I've removed the open handles check, should exit now. |
Firefox crashes for some reason, dunno why. Good to merge otherwise. |
// Launches unused browser just to get the browser version. | ||
const inactiveBrowser = await this.library.launch(launchOptions); | ||
this._browserVersion = inactiveBrowser.version(); | ||
inactiveBrowser.close().catch((error) => { |
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.
not await
ing here is on purpose? if so, what is the reason?
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.
I'm +1 for awaiting here but Ondra had said that we should skip this so I followed.
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.
We don't want to slow down just to make the version
work. Nothing more really.
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.
Alternatively we could use CDP for this https://chromedevtools.github.io/devtools-protocol/tot/Browser/#method-getVersion but IIRC we cannot connect to CDP with persistent context, that's a playwright limitation.
page.once('close', async () => { | ||
this.activePages--; | ||
|
||
await close(); |
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.
This is quite unsafe because the page may open popups and get closed after opening them.
Yeah, I see. But at the same time, closing those extra pages as well might be unexpected for users. Let's live with it and see if it causes any problems. The browsers have a hard kill interval anyway.
@mnmkng I have to head out to uni, feel free to merge this or I'll merge this tomorrow afternoon |
I need to test this firstdone