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

fix: handle server-timing header merging #26

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Nytelife26
Copy link
Contributor

@Nytelife26 Nytelife26 commented Jun 24, 2024

Fixes #25.

This should also make us immune to further silliness, in case they add anything else.

@martinbrose
Copy link
Owner

Sorry @Nytelife26,

I did a quick fix myself. I didn't notice that you already raised a pull request.
I noticed though that we seem to have done it the same but in different order.

When I look at the output, it seems there is some additional text at the end, divided by a comma. Hence I cut it at the comma and take the first element.

Is your approach, first comma then equals sign, more robust perhaps?

@Nytelife26
Copy link
Contributor Author

Nytelife26 commented Jun 25, 2024

When I look at the output, it seems there is some additional text at the end, divided by a comma. Hence I cut it at the comma and take the first element.

Is your approach, first comma then equals sign, more robust perhaps?

My logic here was that each entry of the header is divided by a comma (this will continue if more are added), so it should split by those first, then extract the value from the entry. I can't imagine the other way around would cause a problem. Both approaches will break if the order of entries changes anyway. The most technically correct solution would be to parse the entries, but that logic would be complex and introduce notable latencies in processing results.

Ultimately, it's your call which you'd rather use, or if you want me to attempt to implement something less quick and dirty.

Copy link
Contributor Author

@Nytelife26 Nytelife26 left a comment

Choose a reason for hiding this comment

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

The latest commit introduces the same system that Cloudflare uses for consistency and more robust handling.

Comment on lines +197 to +198
timing_match = TIMING_DURATION_RE.search(r.headers["Server-Timing"])
coll.server.append(float(timing_match.group(1)) / 1e3)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

In its current state, this change is fallible - much like before, but in a way that will crash instead of returning an erroneous value. We could handle this condition, but short of reporting None to invalidate the entire test, it would involve some compromise.

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.

error parsing response headers
2 participants