This commit is contained in:
Tienson Qin
2026-03-01 10:52:27 +08:00
parent 01d15fe508
commit 7b6d7b4401
2 changed files with 7 additions and 21 deletions

View File

@@ -373,12 +373,9 @@
(p/let [current-session (<get-session self)]
(when (= session-id (:id current-session))
(let [event-type (or (:type payload) "agent.runtime")]
(p/let [_ (<append-event! self {:type event-type
:data payload
:ts (common/now-ms)})
current-session (<get-session self)]
(when (runtime-auto-terminate-status? (:status current-session))
(<terminate-runtime! self (:runtime current-session))))))))
(<append-event! self {:type event-type
:data payload
:ts (common/now-ms)})))))
(defn- <consume-events-stream! [^js self session-id runtime on-ready]
(let [provider (runtime-provider/resolve-provider (.-env self) runtime)]

View File

@@ -1083,19 +1083,8 @@
(str "/v1/sessions/" session-id "/terminate")
{:token agent-token}))
(defn- <cloudflare-delete-sandbox! [^js sandbox]
(cond
(js-method sandbox "delete")
(->promise (.delete sandbox))
(js-method sandbox "remove")
(->promise (.remove sandbox))
(js-method sandbox "destroy")
(->promise (.destroy sandbox))
:else
(p/resolved nil)))
(defn- <cloudflare-destroy-sandbox! [^js sandbox]
(->promise (.destroy sandbox)))
(defn- <cloudflare-open-terminal!
[^js env runtime request {:keys [cols rows]}]
@@ -1474,8 +1463,8 @@
(p/catch
(<cloudflare-terminate-session! sandbox port agent-token session-id)
(fn [_] nil)))
_ (p/catch (<cloudflare-delete-sandbox! sandbox)
(fn [_] nil))]
result (<cloudflare-destroy-sandbox! sandbox)]
(log/info ::destroy-sandbox-result result)
nil)
(fn [_] nil)))))))