v0.16.4
Patch Changes
-
f1048ba: Fix: the widget could report "Online" and then fail every send
A visitor on smoo.ai completed the pre-chat form, saw the status go "Online", and then got "We couldn't reach the chat." on every turn while the backend was entirely healthy. Three defects, all on the connect path:
connect()early-returned while a connect was in flight. The guard was right — one connect, not two — but it returned an already-resolved promise, so everyawait connect()resolved before a session existed andsend()fell through to its "not connected" throw. Four of the six call sites are fire-and-forgetvoid connect()(launcher click, pre-chat submit, full-page mount, voice hand-off), so an awaiting caller racing an in-flight one is the normal case, not an edge. Concurrent callers now share one connect and eachawaitresolves when that connect finishes.- A
create_conversation_sessionthat resolved without a session id was accepted, assigningundefinedand still flipping the status toready. That is a permanent wedge: every later send hits the missing id, callsconnect(), is early-returned by thereadystatus, and throws again. It now fails honestly and retryably. tryResume()read the session snapshot'sstatusoutside itstry/catch. The operator client returns animmediate_response'sdatawithout checking its status, so an error-status reply carrying nodataresolves asundefinedrather than rejecting — and the property read threw aTypeErrorpast the catch and out ofconnect().
Also hardened:
send()now renders the one human error sentence when a connect is genuinely fatal, instead of rejecting out ofsend()— which dropped the visitor's typed text into an empty transcript and raised an unhandled rejection on the host page. A failure reaching the optional resume probe is recoverable by starting a fresh session; a failure reaching the transport itself stays fatal.