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: Memoize Singed.output_directory to prevent path override #42

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

Conversation

benaitcheson
Copy link

@benaitcheson benaitcheson commented Feb 21, 2025

Problem

After setting Singed.output_directory = "flamegraphs/" inside development.rb the gem initialisation defaults it back to "tmp/speedscope"

Solution

Added memoization using the ||= operator to cache the computed path after its first calculation. This ensures that:

  • The path is only computed once during Rails initialization
  • The original fallback behavior is preserved if a custom path is set before initialization

Impact

  • Reduces unnecessary path computations
  • Maintains compatibility with existing custom path configurations
  • No breaking changes to the public API

Testing

  • Verified that the output directory is correctly set on initialization
  • Confirmed that custom paths set before initialization are not overwritten

Resulting stacktrace from server after change with bundle open
image

Before hand:
image

development.rb setup
image

@benaitcheson
Copy link
Author

@technicalpickles Would I be able to get a review on this one please. Thanks.

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.

1 participant