Skip to content

Commit dab8562

Browse files
committed
Make portal.runtime/id globally unique per process
This will avoid issues with cache eviction after re-connection and other potential issues with implicitly scoping ids per web socket connection.
1 parent 74b0099 commit dab8562

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/portal/runtime.cljc

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@
1515
(print (:rep value))))
1616

1717
(defonce default-options (atom nil))
18+
(defonce ^:private last-id (atom 0))
1819

1920
(defonce ^:dynamic *session* nil)
20-
(defn- next-id [] (swap! (:id *session*) inc))
21+
(defn- next-id [] (swap! last-id inc))
2122
(defonce sessions (atom {}))
2223

2324
(defn get-session [session-id]
@@ -29,8 +30,7 @@
2930
(defn open-session [{:keys [session-id] :as session}]
3031
(merge
3132
(get-session session-id)
32-
{:id (atom 0)
33-
:value-cache (atom {})
33+
{:value-cache (atom {})
3434
:watch-registry (atom #{})}
3535
session))
3636

0 commit comments

Comments
 (0)