Created
January 12, 2021 16:26
-
-
Save moofkit/e1bf1ca0d3186aa7f9b89d3c3ee7fc58 to your computer and use it in GitHub Desktop.
sentry-havy-serialize-reproduce
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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:[email protected]/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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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