Skip to content

Remove debug output#21

Open
n-rodriguez wants to merge 2 commits intotrailblazer:masterfrom
n-rodriguez:wip/fix_output
Open

Remove debug output#21
n-rodriguez wants to merge 2 commits intotrailblazer:masterfrom
n-rodriguez:wip/fix_output

Conversation

@n-rodriguez
Copy link
Copy Markdown

Reopen #20

…[]).inspect` in a controller

Stacktrace:

/Users/nicolas/PROJECTS/CONCERTO/concerto/.bundle/ruby/3.3.0/bundler/gems/trailblazer-endpoint-827ac62bdb4c/lib/trailblazer/endpoint/options.rb:80:in `block in CallDirective': no implicit conversion of nil into Hash (TypeError)

          config = callable.(ctx, **ctx) # e.g. ApplicationController.options_for_endpoint

def self.CallDirective(callable, option_name)
->((ctx, flow_options), *) {
ctx ||= {}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Using ||= usually implies you have lost track of how your data flows, it's always an anti-pattern for me! In what cases is that required for you, if I may ask?

Also, off-topic, @n-rodriguez may I ask you some questions on https://trailblazer.zulipchat.com of how you use endpoint? Background is, I have another branch where I threw out a lot of complex logic of this gem and changed the runtime API and I'd like to hear a user's thoughts (and so far, you're the only user I know hahaha). ☕

Copy link
Copy Markdown
Author

@n-rodriguez n-rodriguez Apr 30, 2024

Choose a reason for hiding this comment

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

In what cases is that required for you, if I may ask?

For debugging :)

When I run this code without the patch (in config/puma.rb) :

before_fork do
  PumaSettings.info '* Finalizing master process'

  #puts CampingsController.instance_variable_get('@normalizers')[:endpoints].call([]).inspect
  puts ConcertoFrance::PagesController.instance_variable_get('@normalizers')[:endpoints].call([]).inspect

  3.times { GC.start }
  GC.compact

  #puts CampingsController.instance_variable_get('@normalizers')[:endpoints].call([]).inspect
  puts ConcertoFrance::PagesController.instance_variable_get('@normalizers')[:endpoints].call([]).inspect
end

it fails with this error :

/Users/nicolas/PROJECTS/CONCERTO/concerto/.bundle/ruby/3.3.0/bundler/gems/trailblazer-endpoint-827ac62bdb4c/lib/trailblazer/endpoint/options.rb:80:in `block in CallDirective': no implicit conversion of nil into Hash (TypeError)

          config = callable.(ctx, **ctx) # e.g. ApplicationController.options_for_endpoint

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

With this patch we can see the Ruby GC bug : trailblazer/trailblazer-activity#60 (comment)

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