Skip to content

Instantly share code, notes, and snippets.

@moofkit
Created January 12, 2021 16:26
Show Gist options
  • Save moofkit/e1bf1ca0d3186aa7f9b89d3c3ee7fc58 to your computer and use it in GitHub Desktop.
Save moofkit/e1bf1ca0d3186aa7f9b89d3c3ee7fc58 to your computer and use it in GitHub Desktop.
sentry-havy-serialize-reproduce
# frozen_string_literal: true
begin
require "bundler/inline"
rescue LoadError => e
$stderr.puts "Bundler version 1.10 or later is required. Please update your Bundler"
raise e
end
gemfile(true) do
source "https://rubygems.org"
# Activate the gem you are reporting the issue against.
gem 'rack', '1.6.13'
gem 'sentry-raven', '3.0.0', require: 'sentry-raven-without-integrations'
gem 'grape', '1.2.4'
end
require 'raven'
require 'raven/transports/dummy'
Raven.configure do |config|
config.dsn = "dummy://12345:67890@sentry.localdomain/sentry/42"
end
class HavySerializeObject
def to_s
sleep 5
"boom"
end
end
class TestApp < Grape::API
rescue_from :all do |e|
env['somelarge.object'] = HavySerializeObject.new
Raven::Rack.capture_exception(e, env)
Rack::Response.new({ error: 'An error ocurred' }.to_json, 500, { "Content-type" => "application/json" })
end
get :hello do
{ hello: 'world' }
end
get :exception do
raise "boom"
end
format :json
end
module RackApplication
class << self
def to_app
@rack_application ||= build
end
private
def build
builder = Rack::Builder.new
builder.use Raven::Rack
builder.run TestApp.new
builder
end
end
end
run RackApplication.to_app
start:
rackup config.ru -p 9292
test:
time curl 'http://localhost:9292/exception'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment