Browser REPL: Fail if rapidly entering forms, Safari, older Mac

Description

If you rapidly enter forms into the browser REPL when connected to Safari, it will ultimately fail (usually within 20 forms, but sometimes within 100) with Safari indicating

At this point, the response to the evaluated form will not be sent back to the terminal REPL, and the terminal REPL will block awaiting a promise that will never be fulfilled:

This is also reproducible with Safari Technology Preview, but not with Chrome or FireFox.

One way to reproduce the issue is to make a file containing one form per line (say, a list of integers), and to cat that file into the REPL:

Then connect to http://localhost:9000 with Safari.

Another way to reproduce the error is to use a program to drive the REPL. Here is one that can be executed in a Clojure REPL:

Then connect to http://localhost:9000 with Safari.

The above program includes JavaScript console logging, so you can see the count increase in the browser console until failure occurs.

Interestingly, it was empirically found that if you comment out the Content-Length header here, then the problem goes away:

https://github.com/clojure/clojurescript/blob/7aca40c4b6131b8e08153809a410c06bdfa567ab/src/main/clojure/cljs/repl/server.clj#L166

This was inspired by a description of the way Safari handles this header, and how it can produce the error being seen https://apple.stackexchange.com/a/107868

Note that this is unrelated to the new gzip code; I tried a test disabling the gzip feature and the problem still occurs with it disabled.

Environment

{:deps {org.clojure/clojurescript {:mvn/version "1.10.138"}}}
Safari
2009 model iMac

Assignee

Unassigned

Reporter

Mike Fikes

Labels

None

Approval

None

Patch

None

Priority

Minor
Configure