Skip to content

Instantly share code, notes, and snippets.

@etehtsea
Created March 24, 2015 23:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save etehtsea/9bd1f2ccc69d5c3490cc to your computer and use it in GitHub Desktop.
Save etehtsea/9bd1f2ccc69d5c3490cc to your computer and use it in GitHub Desktop.
bugsnag
Gem::Specification.new do |spec|
spec.name = "bugsnag_threading_issue"
spec.version = '0.0.1'
spec.files = `git ls-files -z`.split("\x0")
spec.require_paths = ["."]
spec.add_dependency 'pry'
spec.add_dependency 'rack', '~> 1.5.0'
spec.add_dependency 'bugsnag', '2.8.1'
spec.add_development_dependency "bundler", "~> 1.7"
end
require 'bugsnag'
require 'bugsnag/rack'
require 'rack'
Bugsnag.configure do |c|
c.project_root = File.expand_path('..', ENV['BUNDLE_GEMFILE'])
c.logger = Logger.new('/dev/null')
end
module BugsnagThreadingIssue
# jruby -G -S rackup
class App
def initialize
@app = Rack::Builder.new do
use Bugsnag::Rack
map('/') do
run ->(_) do
count = Bugsnag.configuration.middleware.instance_variable_get(:@middlewares).count
p "Bugsnag middlewares: #{count}"
[200, {'Content-Type' => 'application/json' }, ["{\"middlewares\":#{count}}"]]
end
end
end
end
def call(env)
@app.call(env)
end
end
# Command to reproduce: jruby -G -r"bugsnag_threading_issue" -e "BugsnagThreadingIssue::Core.reproduce"
class Core
def initialize
1024.times.map do
Thread.new do
Bugsnag::Rack.new(->(_) { sleep 1; ['200', {}, ['']] }).call({})
end
end.map(&:value)
end
def self.reproduce
loop { p new }
end
end
end
require 'bugsnag_threading_issue'
run BugsnagThreadingIssue::App.new
source 'https://rubygems.org'
# Specify your gem's dependencies in bugsnag_threading_issue.gemspec
gemspec
PATH
remote: .
specs:
bugsnag_threading_issue (0.0.1)
bugsnag (= 2.8.1)
pry
rack (~> 1.5.0)
GEM
remote: https://rubygems.org/
specs:
bugsnag (2.8.1)
multi_json (~> 1.0)
coderay (1.1.0)
ffi (1.9.8-java)
method_source (0.8.2)
multi_json (1.11.0)
pry (0.10.1-java)
coderay (~> 1.1.0)
method_source (~> 0.8.1)
slop (~> 3.4)
spoon (~> 0.0)
rack (1.5.2)
slop (3.6.0)
spoon (0.0.4)
ffi
PLATFORMS
java
DEPENDENCIES
bugsnag_threading_issue!
bundler (~> 1.7)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment