Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions config/puma.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,14 @@
require_relative "../app/lib/credentials"

Credentials.load if ENV["DOPPLER_TOKEN"]

# https://docs.appsignal.com/ruby/integrations/puma.html#usage-with-preload_app
# Add this before_fork callback to stop the minutely probes in the Puma main process
before_fork do
Appsignal::Probes.stop
end

# Add this on_worker_boot callback to start the minutely probes in the Puma worker processes
on_worker_boot do
Appsignal::Probes.start
end
Comment on lines +57 to +64
Copy link

Choose a reason for hiding this comment

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

Bug: Incorrect AppSignal method names Appsignal::Probes.stop and Appsignal::Probes.start are used in Puma callbacks, leading to NoMethodError.
Severity: CRITICAL | Confidence: High

🔍 Detailed Analysis

The code in config/puma.rb calls incorrect method names on the AppSignal gem: Appsignal::Probes.stop and Appsignal::Probes.start. When Puma executes these callbacks in non-development environments (where preload_app! is enabled), it will attempt to call methods that do not exist on the AppSignal gem. This will raise a NoMethodError or NameError. In the before_fork callback, the Puma master process will crash before it can fork workers. In the on_worker_boot callback, each worker process will crash before it can accept requests, causing the application to fail to start in production.

💡 Suggested Fix

Replace Appsignal::Probes.stop with Appsignal.stop_probes and Appsignal::Probes.start with Appsignal.start_probes in config/puma.rb.

🤖 Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: config/puma.rb#L57-L64

Potential issue: The code in `config/puma.rb` calls incorrect method names on the
AppSignal gem: `Appsignal::Probes.stop` and `Appsignal::Probes.start`. When Puma
executes these callbacks in non-development environments (where `preload_app!` is
enabled), it will attempt to call methods that do not exist on the AppSignal gem. This
will raise a `NoMethodError` or `NameError`. In the `before_fork` callback, the Puma
master process will crash before it can fork workers. In the `on_worker_boot` callback,
each worker process will crash before it can accept requests, causing the application to
fail to start in production.

Did we get this right? 👍 / 👎 to inform future reviews.
Reference ID: 3466918