I made the mistake of calling Dream.set_session_field from the callback passed to Dream.sql. Since I had configured sessions to be stored in the SQL database, Dream.set_session_field itself called Dream.sql, immediately leading to a deadlock for this client. Below is a minimal reproducible example.
let main request =
Dream.sql request (fun _ ->
let%lwt () = Dream.set_session_field request "will" "deadlock" in
Dream.respond "unreachable")
let () =
Dream.run @@ Dream.logger @@ Dream.sql_pool "sqlite3:db.sqlite"
@@ Dream.sql_sessions @@ Dream.router [Dream.get "/" main]
As a newcomer to web development, I am not sure whether this behavior is considered reasonable or not. If it is, perhaps it should be mentioned in the documentation.
I made the mistake of calling
Dream.set_session_fieldfrom the callback passed toDream.sql. Since I had configured sessions to be stored in the SQL database,Dream.set_session_fielditself calledDream.sql, immediately leading to a deadlock for this client. Below is a minimal reproducible example.As a newcomer to web development, I am not sure whether this behavior is considered reasonable or not. If it is, perhaps it should be mentioned in the documentation.