-
Notifications
You must be signed in to change notification settings - Fork 765
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
Browser Pool does not await _createPageForBrowser #2789
Comments
hey @B4nan , this issue is assigned to you!.. are you working on this if not then I would love to work on this |
Feel free to look into it. |
my approach would be By adding await before _createPageForBrowser() in both functions |
I am having a hard time understanding how the added awaits in #2860 could help. Both places are async, we are not ignoring any promise in there. By adding the await we only make sure the promise is finished before we return. @danielcrabtree can you confirm #2860 is what helped on your end? I don't mind merging that, it just feels weird that this could cause a race condition. |
I was specifically having the issue with newPage. I'm unsure if the problem occurs with newPageInNewBrowser as I wasn't using that and since it does not appear to use limiter, maybe race conditions are not an issue in that case? My understanding of the issue is that limiter is designed to run the inline async function with concurrency of 1 to avoid race conditions between parallel browser actions. By not awaiting _createPageForBrowser within the limiter context, this opens up the possibility of race conditions between that operation and parallel browser launches as the _createPageForBrowser method can (and in my case sometimes was) complete after exiting from the limiter context. Adding the await to the call to _createPageForBrowser in newPage fixed the race condition for me. I was never able to produce a minimum example that reliably triggered the issue to prove this fixed it, but it's been over a month now and I have yet to see the issue. |
Which package is this bug report for? If unsure which one to select, leave blank
@crawlee/browser-pool
Issue description
The newPage and newPageInNewBrowser functions in BrowserPool both return _createPageForBrowser() without awaiting the result. This causes the browser to hang under certain difficult to reproduce race conditions - adding await to these calls appears to resolve these race conditions.
Code sample
No response
Package version
3.12.1
Node.js version
22
Operating system
No response
Apify platform
I have tested this on the
next
releaseNo response
Other context
No response
The text was updated successfully, but these errors were encountered: