FIX: Ensure RequestTracker handles bubbled exceptions correctly (#26940)

This can happen for various reasons including rate limiting and middleware bugs. This should resolve the warning we're seeing in the logs

```
RequestTracker.get_data failed : NoMethodError : undefined method `[]' for nil:NilClass
```
This commit is contained in:
David Taylor
2024-05-08 16:08:39 +01:00
committed by GitHub
parent c8faf3e427
commit ece0150cb7
2 changed files with 21 additions and 0 deletions

View File

@@ -120,7 +120,10 @@ class Middleware::RequestTracker
def self.get_data(env, result, timing, request = nil)
status, headers = result
# result may be nil if the downstream app raised an exception
status = status.to_i
headers ||= {}
request ||= Rack::Request.new(env)
helper = Middleware::AnonymousCache::Helper.new(env, request)