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

Add error return value from page.on handlers #1495

Merged
merged 5 commits into from
Oct 25, 2024

Conversation

ankur22
Copy link
Collaborator

@ankur22 ankur22 commented Oct 18, 2024

What?

This adds an error return value from the page.on handlers.

Why?

It's being more defensive to ensure that when an error occurs (due to the iteration ending) we exit early and don't try to process any other handlers, and to ensure that we don't use incorrect url name values when a page,.on(metric) handler returns early.

Checklist

  • I have performed a self-review of my code
  • I have added tests for my changes
  • I have commented on my code, particularly in hard-to-understand areas

Related PR(s)/Issue(s)

Relates to: #1493 (comment)

This will make it simpler to read and maintain the page.on handler
code.
When the context is closed, we should return an error to notify the
user that not all handlers completed execution.
The most important thing to do is to handle the error and ensure that
the page.on metric returns false so that the metric tag isn't update.
This is being defensive, since the context has already closed and the
metric emitter will not emit a metric when the context has closed.

We're logging a debug log here since this information will not benefit
the end user and when this error occurs they can't action on it. It
could be useful for debugging though.
Mainly useful for debugging purposes, but otherwise this isn't really
needed except to ensure we exit asap from the for loop when the
context has ended and therefore the iteration has ended.
Copy link
Member

@inancgumus inancgumus left a comment

Choose a reason for hiding this comment

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

Nice, but we need to take these debugs and errors under control to reduce verbosity (my comment is not specific to this PR :)).

@ankur22
Copy link
Collaborator Author

ankur22 commented Oct 25, 2024

Nice, but we need to take these debugs and errors under control to reduce verbosity (my comment is not specific to this PR :)).

Yeah, definitely agree.

@ankur22 ankur22 merged commit 18cbe37 into main Oct 25, 2024
23 checks passed
@ankur22 ankur22 deleted the update/page-on-handler-with-error branch October 25, 2024 09:38
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.

2 participants