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

feat: capture additional logs for proxy #302

Merged
merged 2 commits into from
Nov 7, 2024

Conversation

cristianoventura
Copy link
Collaborator

@cristianoventura cristianoventura commented Nov 7, 2024

Description

When the proxy fails to start, the only line outputted to the log file is the following:

[2024-11-07 10:53:51.755] [error] Error logged during startup, exiting...

This happens because mitmproxy outputs some errors to stdout and, we are not capturing them.

With the changes in this PR, the log file will look like this when the proxy port is already in use, but additional information will be captured regardless of the error:

[2024-11-07 10:48:52.998] [error] Error logged during startup, exiting...
[2024-11-07 10:48:52.999] [error] [10:48:52.998] [Errno 48] HTTP(S) proxy (upstream mode) failed to listen on *:6001 with [Errno 48] error while attempting to bind on address ('0.0.0.0', 6001): address already in use
[2024-11-07 10:48:53.000] [error] Try specifying a different port by using `--mode upstream:localhost:200@6003`.
[2024-11-07 10:48:53.000] [error] Proxy failed to start on port 6001, restarting...

How to Test

  • launch a separate instance of k6 Studio (such as a production build using a valid port or, start mitmproxy on your terminal mitmproxy --mode regular@6001)
  • launch k6 studio using this branch and change the port to the same as the other instance. Make sure the "Automatically find port" option is disabled
  • the proxy should fail to launch due to the port being busy
  • check the log file

Checklist

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

Screenshots (if appropriate):

Related PR(s)/Issue(s)

@cristianoventura cristianoventura self-assigned this Nov 7, 2024
@cristianoventura cristianoventura requested a review from a team as a code owner November 7, 2024 16:04
@cristianoventura cristianoventura requested review from going-confetti and Llandy3d and removed request for a team November 7, 2024 16:04
@cristianoventura cristianoventura changed the title feat: additional logs for proxy feat: capture additional logs for proxy Nov 7, 2024
Copy link
Member

@Llandy3d Llandy3d left a comment

Choose a reason for hiding this comment

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

LGTM!

@cristianoventura cristianoventura merged commit 685bac9 into main Nov 7, 2024
2 checks passed
@cristianoventura cristianoventura deleted the feat/additional-proxy-logs branch November 7, 2024 19:42
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