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

Explicitly check if we actually timed out #4132

Merged
merged 2 commits into from
Jan 3, 2025
Merged

Explicitly check if we actually timed out #4132

merged 2 commits into from
Jan 3, 2025

Conversation

olegbespalov
Copy link
Contributor

@olegbespalov olegbespalov commented Dec 18, 2024

What?

It's an attempt to address a nil pointer from #4128

Unfortunately, we don't have a script/steps to reproduce the #4128, but after analyzing the stack trace and code it seems like one of the possible scenarios what happens is that we reached the default (30s) context timeout which causing context deadline, somewhere down the createWaitForEventHandler it exits the releases the channel and as result we didn't fill the page.

So we will always check the context error to check if it was timed out and also explicitly check if we were able to fetch non-nil page (the main purpose of the method)

Why?

Fix the panic and error explicit.

Checklist

  • I have performed a self-review of my code.
  • I have added tests for my changes.
  • I have run linter locally (make lint) and all checks pass.
  • I have run tests locally (make tests) and all tests pass.
  • I have commented on my code, particularly in hard-to-understand areas.

Related PR(s)/Issue(s)

Fixes #4128

@olegbespalov olegbespalov self-assigned this Dec 18, 2024
@olegbespalov olegbespalov marked this pull request as ready for review December 20, 2024 08:08
@olegbespalov olegbespalov requested a review from a team as a code owner December 20, 2024 08:08
@olegbespalov olegbespalov requested review from inancgumus, ankur22, mstoykov and joanlopez and removed request for a team, inancgumus and mstoykov December 20, 2024 08:08
mstoykov
mstoykov previously approved these changes Dec 20, 2024
ankur22
ankur22 previously approved these changes Dec 20, 2024
b.logger.Debugf("Browser:newPageInContext:<-ctx.Done", "tid:%v bctxid:%v err:%v", tid, id, ctx.Err())
}

if err = ctx.Err(); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

Could this context be cancelled because any reason other than context.DeadlineExceeded? Perhaps, in a future iteration of this code, we might want to introduce that explicit check or use cause.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My understanding (@ankur22, please correct me if I am wrong) even if that happens it's still an error case

Copy link
Contributor

Choose a reason for hiding this comment

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

Correct, any error from context is regarded as an error and we should return an error back to the user to notify them of an issue. If the context is closed at this point, it will mean that the iteration has ended.

Copy link
Contributor

Choose a reason for hiding this comment

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

Right! What I was wondering is whether context.DeadlineExceeded should be considered a timeout error, but context.Canceled shouldn't (but as an unknown). But both errors, yeah.

joanlopez
joanlopez previously approved these changes Dec 20, 2024
@olegbespalov
Copy link
Contributor Author

olegbespalov commented Dec 20, 2024

I think I messed up the force push

Nope, it's just GH UI tricked me

@ankur22 ankur22 merged commit 32e5189 into master Jan 3, 2025
29 checks passed
@ankur22 ankur22 deleted the fix/nil-page branch January 3, 2025 10:00
@ankur22 ankur22 added this to the v0.56.0 milestone Jan 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Panic (NPD): browser.mapPage -> Page.GetKeyboard
4 participants