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

Don't suppress view component rendering errors #2410

Merged

Conversation

mjacobus
Copy link
Contributor

@mjacobus mjacobus commented Jan 23, 2024

Before contributing, please read our contributing guidelines and code of conduct.

Overview

Fixes a bug introduced in #2367, where the render_in behavior was changed, suppressing errors.

We should be able to se error pages, specially in when Rails.env is development. The piece of code that was removed here prevented from happening. Instead, it would have the render_in method return nil when an error happened, resulting in either a blank page, or an incomplete page.

I believe we also want to raise errors in production. We should not make a decision here, whether the error should be suppressed. Otherwise we are making the assumption "incomplete pages are better than error pages", which may be the correct assumption under some circumstances, but not under other circumstances.

Fixes ViewComponent/view_component#1981

Submitter Checklist:

  • Include a link to the related GitHub issue, if applicable
  • Include a security review link, if applicable

Testing

The agent includes a suite of unit and functional tests which should be used to
verify your changes don't break existing functionality. These tests will run with
GitHub Actions when a pull request is made. More details on running the tests locally can be found
here for our unit tests,
and here for our functional tests.
For most contributions it is strongly recommended to add additional tests which
exercise your changes.

Reviewer Checklist

  • Perform code review
  • Add performance label
  • Perform appropriate level of performance testing
  • Confirm all checks passed
  • Add version label prior to acceptance

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@github-actions github-actions bot added the community To tag external issues and PRs submitted by the community label Jan 23, 2024
@mjacobus mjacobus changed the title 🐛 Don't suppress view component rendering errors Don't suppress view component rendering errors Jan 23, 2024
@mjacobus mjacobus force-pushed the fix-view-component-instrumentation branch from a0e8887 to 3b93d47 Compare January 23, 2024 19:47
@@ -14,8 +14,6 @@ def render_in_with_tracing(*args)
name: metric_name(self.class.identifier, self.class.name)
)
yield
rescue => e
::NewRelic::Agent.logger.debug('Error capturing ViewComponent segment', e)
Copy link
Contributor

Choose a reason for hiding this comment

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

Hi @mjacobus! Thank you for catching this—we shoudn't be swallowing errors! But we do want to capture and report them to New Relic. Could you update your code to the following?

rescue => e
  NewRelic::Agent.notice_error(e)
  raise

Then we can get this merged ◡̈

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure thing! There you go. Thank you @hannahramadan

We should be able to se error pages, specially in when Rails.env is
development. The piece of code that was removed here
prevented from happening. Instead, it would have the `render_in` method
return `nil` when an error happened, resulting in either a blank page,
or an incomplete page.

I believe we also want to raise errors in production. We should not make
a decision here, whether the error should be suppressed. Otherwise we
are making the assumption "incomplete pages are better than error
pages", which may be the correct assumption under some circumstances,
but not under other circumstances.

Fixes ViewComponent/view_component#1981
@mjacobus mjacobus force-pushed the fix-view-component-instrumentation branch from 3b93d47 to becdad9 Compare January 24, 2024 10:43
@hannahramadan hannahramadan merged commit 7e117f2 into newrelic:dev Jan 24, 2024
23 of 24 checks passed
@hannahramadan
Copy link
Contributor

Thank you @mjacobus! We will followup once these changes are released.

@mjacobus mjacobus deleted the fix-view-component-instrumentation branch January 24, 2024 19:44
@hannahramadan
Copy link
Contributor

Hi @mjacobus—Ruby agent 9.7.1 has been released and includes this fix. Thanks again for your help on this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community To tag external issues and PRs submitted by the community
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Component renders "" (blank) when an error is raised during the render phase
3 participants