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

[Miniflare 3] Use http.STATUS_CODES for logging status text #616

Merged
merged 1 commit into from
Jun 29, 2023

Conversation

mrbbot
Copy link
Contributor

@mrbbot mrbbot commented Jun 27, 2023

Some responses, especially those from custom services, don't have a statusText. This means some logs only include a status code. We can derive the text from just the code using the http.STATUS_CODES constants built into Node.

@mrbbot mrbbot requested a review from a team June 27, 2023 16:02
@changeset-bot
Copy link

changeset-bot bot commented Jun 27, 2023

⚠️ No Changeset found

Latest commit: 1868834

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@@ -144,7 +144,6 @@ function maybeLogRequest(
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
status: response.status,
statusText: response.statusText,

Choose a reason for hiding this comment

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

Is there any scenario where response.statusText is different to what would be retrieved from http.STATUS_CODES? I.e. should we try using this first and fall back to the lookup if not available?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Technically, you can specify any value you want I think. Trying the value then falling back seems like a good idea. 🙂 👍

@mrbbot mrbbot force-pushed the bcoll/tre-status-text-from-http branch from 95ed886 to 811e9ae Compare June 28, 2023 14:21
@mrbbot mrbbot requested a review from petebacondarwin June 28, 2023 14:21
Some responses, especially those from custom services, don't have a
`statusText`. This means some logs only include a status code.
We can derive the text from just the code using the
`http.STATUS_CODES` constants built into Node.
@mrbbot mrbbot force-pushed the bcoll/tre-status-text-from-http branch from 811e9ae to 1868834 Compare June 29, 2023 14:59
@mrbbot mrbbot merged commit 5145bcc into tre Jun 29, 2023
@mrbbot mrbbot deleted the bcoll/tre-status-text-from-http branch June 29, 2023 15:10
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