File tree Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change
1
+ ## current
2
+
3
+ - lwt_jsoo: Fix ` Lwt.wakeup_exn ` ` Invalid_arg ` exception when a js
4
+ stack overflow happens in the XHR completion handler (@mefyl #762 ).
5
+
1
6
## v4.0.0 (2021-03-24)
2
7
3
8
- cohttp.response: fix malformed status header for custom status codes (@mseri @aalekseyev #752 )
Original file line number Diff line number Diff line change @@ -231,7 +231,20 @@ module Make_client_async (P : Params) = Make_api (struct
231
231
* Remove the type constraint on Lwt.task above and return any old
232
232
* guff here. It'll compile and crash in the browser! *)
233
233
Lwt. wakeup wake (response, body)
234
- with e -> Lwt. wakeup_exn wake e)
234
+ with
235
+ | e
236
+ (* If we exhaust the stack, it is possible that
237
+ Lwt.wakeup just aboves marks the promise as
238
+ completed, but raises Stack_overflow while
239
+ running the promise callbacks. In this case
240
+ waking calling wakeup_exn on the already
241
+ completed promise would raise an Invalid_arg
242
+ exception, so although the promise is in a
243
+ really bad state we may as well let the actual
244
+ Stack_overflow exception go through. *)
245
+ when Lwt. state res = Lwt. Sleep
246
+ ->
247
+ Lwt. wakeup_exn wake e)
235
248
| _ -> () );
236
249
237
250
(* perform call *)
You can’t perform that action at this time.
0 commit comments