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 stackprof not installed error #547

Merged
merged 1 commit into from Apr 5, 2023

Conversation

gmcgibbon
Copy link
Contributor

@gmcgibbon gmcgibbon commented Feb 7, 2023

Fixes malformed response when pp=flamegraph is used and stackprof is not installed (this happens on web servers such as puma due to the expectation that the body is an array, it crashes here: https://github.com/puma/puma/blob/d8765e362dd9b273635facefa0911252abdb584b/lib/puma/request.rb#L153).

2023-02-07 15:15:34 -0600 Read: #<NoMethodError: undefined method `each' for "Please install the stackprof gem and require it: add gem 'stackprof' to your Gemfile":String>

Also forwards headers and status code from app response error cases so that app logs are consistent with what is actually returned by middleware.

I couldn't test this through integration tests, so I had to use units. If we don't see value in the well-formed response tests, I can remove them.

@codecov-commenter
Copy link

codecov-commenter commented Feb 7, 2023

Codecov Report

Merging #547 (676bf44) into master (e1d1762) will decrease coverage by 60.57%.
The diff coverage is n/a.

❗ Current head 676bf44 differs from pull request most recent head 9f5a083. Consider uploading reports for the commit 9f5a083 to get more accurate results

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

@@             Coverage Diff             @@
##           master     #547       +/-   ##
===========================================
- Coverage   87.39%   26.82%   -60.57%     
===========================================
  Files          18       14        -4     
  Lines        1269      697      -572     
===========================================
- Hits         1109      187      -922     
- Misses        160      510      +350     

see 17 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@gmcgibbon
Copy link
Contributor Author

Looks like CI errors are due to change in behaviour from the redis client. There's a fix on #543 to get CI green.


expect(100..599).to include(status)
expect(headers.keys).to(all(be_a(String)))
expect(body).to(all(be_a(String)))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Rather than check for an Enumerable of Strings, lets do the Rack-spec thing and check for response to each?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. This caught a bug in the memory profiler spec, so thanks for that!

Copy link
Collaborator

@nateberkopec nateberkopec left a comment

Choose a reason for hiding this comment

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

Spec change and I think it's G2G

@nateberkopec
Copy link
Collaborator

Needs a rebase and then we're set.

Fixes malformed response when pp=flamegraph is used and stackprof is not
installed.

Also forwards headers and status code from app response error cases so
that app logs are consistent with what is actually returned by middleware.
@nateberkopec nateberkopec merged commit c83b710 into MiniProfiler:master Apr 5, 2023
0 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants