Skip to content
This repository was archived by the owner on Jun 30, 2022. It is now read-only.

Commit b382f7a

Browse files
authored
Fix recursive locking when running with config.allow_concurrency = false (#17)
Apparently, the buffering of the response body introduced in #14 causes Rack to fail with a recursive-lock exception when running with `config.allow_concurrency = false`. Unclear why this happens. This reverts the buffering of the response body, though we now appear to be doing precisely what the Rack specification advises against: "Middleware must not call `each` directly on the Body. Instead, middleware can return a new Body that calls `each` on the original Body, yielding at least once per iteration." (https://github.com/rack/rack/blob/d15dd728440710cfc35ed155d66a98dc2c07ae42/SPEC.rdoc#the-body-) Bumped to 0.2.14.
1 parent e99f9dc commit b382f7a

File tree

3 files changed

+3
-13
lines changed

3 files changed

+3
-13
lines changed

Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
akita-har_logger (0.2.13)
4+
akita-har_logger (0.2.14)
55

66
GEM
77
remote: https://rubygems.org/

lib/akita/har_logger.rb

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,6 @@ def call(env)
5555
saved_input = env['rack.input']
5656
env['rack.input'] = StringIO.new request_body
5757

58-
# Buffer the response body in case it's not a rewindable stream.
59-
body = HarLogger.bufferBody(body)
60-
6158
@entry_queue << (HarEntry.new start_time, wait_time_ms, env, status,
6259
headers, body)
6360

@@ -74,19 +71,12 @@ def call(env)
7471
# Logs the given exception.
7572
def self.logException(context, e)
7673
Rails.logger.debug "AKITA: Exception while #{context}: #{e.message} "\
77-
"(#{e.class.name})"
74+
"(#{e.class.name}) in thread #{Thread.current}"
7875
e.backtrace.each { |frame|
7976
Rails.logger.debug "AKITA: #{frame}"
8077
}
8178
end
8279

83-
# Reads the given body into an array and returns the result.
84-
def self.bufferBody(body)
85-
result = []
86-
body.each { |part| result << part }
87-
result
88-
end
89-
9080
# Logging filter for `ActionController`s.
9181
# TODO: Some amount of code duplication here. Should refactor.
9282
class Filter

lib/akita/har_logger/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
module Akita
44
module HarLogger
5-
VERSION = "0.2.13"
5+
VERSION = "0.2.14"
66
end
77
end

0 commit comments

Comments
 (0)