@@ -148,11 +148,13 @@ jsaddleJs = "\
148148 \\n\
149149 \ ws.onopen = function(e) {\n\
150150 \ " <> initState <> "\n\
151− \ var inXhrSend = false;\n\
152151 \\n\
153152 \ ws.onmessage = function(e) {\n\
154− \ if(inXhrSend) return;\n\
155153 \ var batch = JSON.parse(e.data);\n\
154+ \ if(inCallback > 0) {\n\
155+ \ asyncBatch = batch;\n\
156+ \ return;\n\
157+ \ }\n\
156158 \ if(typeof batch === \"string\") {\n\
157159 \ syncKey = batch;\n\
158160 \ var xhr = new XMLHttpRequest();\n\
@@ -167,12 +169,10 @@ jsaddleJs = "\
167169 \\n\
168170 \ " <> runBatch (\a -> "ws.send(JSON.stringify(" <> a <> "));")
169171 (Just (\a -> "(function(){\n\
170− \ inXhrSend = true;\n\
171172 \ var xhr = new XMLHttpRequest();\n\
172173 \ xhr.open('POST', '/sync/'+syncKey, false);\n\
173174 \ xhr.setRequestHeader(\"Content-type\", \"application/json\");\n\
174175 \ xhr.send(JSON.stringify(" <> a <> "));\n\
175− \ inXhrSend = false;\n\
176176 \ return JSON.parse(xhr.response);})()")) <> "\
177177 \ };\n\
178178 \ };\n\