1

I'm giving async Sinatra a try and having a problem.

When using the following simple code:

require 'sinatra'
require 'sinatra/async'

Sinatra.register Sinatra::Async

aget '/delay/?' do
  logger.info "Connected"
  EM.add_timer(5) { body {"delayed for 5 seconds" } }
end

It runs fine when I concurrently request /delay/ with ab, taking 5 secs for all requests.

It does block however when I request /delay/ from within 2 Chrome tabs (or Firefox), and it executes sequentially, causing the 2nd request to take 10 secs.

The funny thing is that requesting it from multiple Safari tabs, again executes fine (in parallel).

Any idea, what might be causing this behavior?

Gem Versions:

gem 'sinatra', "~> 1.3.2"
gem "eventmachine", "1.0.0.beta.4.1"
gem 'thin', "~> 1.3.1"
gem "async_sinatra", "~> 1.0.0"
Kevin Bedell
  • 13,254
  • 10
  • 78
  • 114
gpavlidi
  • 61
  • 5

1 Answers1

0

UPDATE: It seems that the browser cache is what's causing this for both Firefox and Chrome. There can be only 1 active cache write for any URL. Adding a query param will actually fix this.

Source: Multiple Ajax requests for same URL

Community
  • 1
  • 1
gpavlidi
  • 61
  • 5