Name:
[FIX] im_livechat: prevent crash and stale window when leaving session
State:
Failed
finished in 149m
PR State:
merged
PR Author:
David Tran
PR Author Email:
PR:
#1224
Committer:
David Tran
Committer Email:
david.tran@tvtmarine.com
Commit:
24db13593d357b1106d8108633372340c4ca62a8
Description:
[FIX] im_livechat: prevent crash and stale window when leaving session
Closing a livechat conversation fails when the visitor's guest context is
no longer available (the `dgid` cookie expired, was cleared, is blocked as
a third-party cookie on an embedded livechat, or the visitor is in private
browsing).
`/im_livechat/visitor_leave_session` resolves the visitor's
`discuss.channel.member` through the `is_self` domain and calls
`_rtc_leave_call()` on the result. Without a guest context the lookup
returns an empty recordset, so `_rtc_leave_call()` hits `ensure_one()` and
raises `Expected singleton: discuss.channel.member()`, returning a 500.
The exception also prevents `_close_livechat_session()` from running, so
the conversation stays open server-side.
In addition, `LivechatService.leaveSession` removed the saved session from
the storage in a `finally` block, after awaiting the
`visitor_leave_session` RPC. When the visitor leaves the page right after
closing the chat, the in-flight request is aborted and the page is torn
down before the `finally` runs, so the stale session is restored on the
next page load.
Only call `_rtc_leave_call()` when a member is found, always close the
livechat session afterwards, and clear the saved session synchronously
before notifying the server.
Branch:
17.0
Instance ID:
0
Age:
Up-time: