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

Set higher default and allow configuring puppeteer protocol timeout #58

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

make-github-pseudonymous-again
Copy link

@make-github-pseudonymous-again make-github-pseudonymous-again commented Jul 23, 2024

I believe this should fix Meteor-Community-Packages/meteor-mocha#104.

@make-github-pseudonymous-again
Copy link
Author

@nachocodoner @jankapunkt @StorytellerCZ Will this require a backport to work in Meteor 2 or is the latest version compatible with both Meteor 2 and 3?

@jankapunkt
Copy link
Member

@make-github-pseudonymous-again it's intended to work with both but please let me know if you encounter issues.

@nachocodoner
Copy link
Member

So, did you stop to see the error after tweaking this timeout? If that is ok, it feels good to me to merge, just tweaking a timeout doesn't seem problematic.

@make-github-pseudonymous-again
Copy link
Author

@nachocodoner If that question is for me, I did not test anything. Just assumed it would work.

@make-github-pseudonymous-again
Copy link
Author

@nachocodoner How could I test this before merging it? I can reproduce this bug locally.

@StorytellerCZ
Copy link
Member

@make-github-pseudonymous-again create a packages folder in your app and in copy this package in there from the PR, that version will then take precedent.

@jankapunkt
Copy link
Member

@make-github-pseudonymous-again cab there be a situation where users might want to set protocolTimeout to 0?

@make-github-pseudonymous-again
Copy link
Author

make-github-pseudonymous-again commented Dec 11, 2024

The protocolTimeout setting in puppeteer is a timeout that is applied to all registered connection message callbacks: if puppeteer does not get a message response within that time, then the connection is considered broken.

It seems the puppeteer driver implemented by Meteor is making puppeteer wait for a message response for the entire duration of the scheduled tests, which can easily reach in the minutes, especially for client app tests.

@jankapunkt protocolTimeout = 0 would be interpreted as "no timeout" AFAICT. See:

Default is 3 minutes. See:

@@ -31,6 +33,7 @@ export default function startPuppeteer({
const browser = await puppeteer.launch({
args: ['--no-sandbox', '--disable-setuid-sandbox'],
headless: 'new',
protocolTimeout: Number.parseInt(process.env.PUPPETEER_PROTOCOL_TIMEOUT, 10) || TWENTY_DAYS,
Copy link
Member

@jankapunkt jankapunkt Dec 11, 2024

Choose a reason for hiding this comment

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

@make-github-pseudonymous-again

protocolTimeout = 0 would be interpreted as "no timeout" AFAICT. See

In that case, your current code would never allow such, because 0 would be evaluated as falsy and thus always fall back to TWENTY_DAYS.

To also support 0 as value, it should be

protocolTimeout: process.env.PUPPETEER_PROTOCOL_TIMEOUT 
  ? Number.parseInt(process.env.PUPPETEER_PROTOCOL_TIMEOUT, 10) 
  : TWENTY_DAYS,

Choose a reason for hiding this comment

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

Makes sense.

Choose a reason for hiding this comment

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

On the other hand, the intention behind twenty days here (copied from Nightmare's default) is perhaps to disable the timeout entirely. So should we instead have the default be 0 instead of TWENTY_DAYS?

Copy link
Member

Choose a reason for hiding this comment

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

@StorytellerCZ what do you think here?

Copy link
Member

Choose a reason for hiding this comment

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

I think 0 should disable timeout, I think that is the intention with this. If nothing is passed then use default.

Choose a reason for hiding this comment

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

OK. I'll update this PR to set "no timeout" as the default, which means passing protocolTimeout = 0 to puppeteer.

Copy link
Member

Choose a reason for hiding this comment

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

That is not what I meant. From my understanding the default right now is TWENTY_DAYS, keep that if there is no input. If the input is something different, including 0, then set it to that. So if the input is 0, then timeout is zero = disabled.

Choose a reason for hiding this comment

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

OK. Had misunderstood. Will apply @jankapunkt's suggestion instead then.

Choose a reason for hiding this comment

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

Suggestion applied.

Choose a reason for hiding this comment

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

@StorytellerCZ Waiting for your input.

@make-github-pseudonymous-again
Copy link
Author

make-github-pseudonymous-again commented Jan 3, 2025

@make-github-pseudonymous-again create a packages folder in your app and in copy this package in there from the PR, that version will then take precedent.

@StorytellerCZ Just tested this. Works: setting a small timeout (5000ms) crashes mid-tests, setting a large timeout lets all tests run to completion. Setting a really small timeout (5ms) crashes during puppeteer setup.

Just out of curiosity, does it matter what name I give to the package under packages/? I named it packages/meteortesting:browser-tests.

Next step is to act on #58 (comment), and then I think it will be ready to merge.

@jankapunkt
Copy link
Member

The folder name is irrelevant as long as it contains the package.js file with proper package config

@make-github-pseudonymous-again make-github-pseudonymous-again force-pushed the feat/allow-configuring-puppeteer-protocol-timeout branch from 7229082 to 093e240 Compare January 3, 2025 17:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

UnhandledPromiseRejectionWarning: Error: Protocol error (Runtime.callFunctionOn): Promise was collected
4 participants