🐛 Fix get-comment-threads called with empty params due to race condition (#9988)

Prevent navigate-to-comment-id from making an RPC call with nil
file-id when current-file-id has been cleared by finalize-workspace
during rapid workspace navigation.  The deferred stream observer
(rx/observe-on :async) could fire after the workspace state was
already cleaned up, causing {:file-id nil} to become {} after
query-string nil-filtering in map->query-string.

Signed-off-by: Andrey Antukh <niwi@niwi.nz>
This commit is contained in:
Andrey Antukh 2026-06-02 17:22:39 +02:00 committed by GitHub
parent e2545915b8
commit a57833f3cd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -274,7 +274,8 @@
(ptk/reify ::navigate-to-comment-id
ptk/WatchEvent
(watch [_ state _]
(let [file-id (:current-file-id state)]
(if-let [file-id (:current-file-id state)]
(->> (rp/cmd! :get-comment-threads {:file-id file-id})
(rx/map #(d/seek (fn [{:keys [id]}] (= thread-id id)) %))
(rx/map navigate-to-comment))))))
(rx/map navigate-to-comment))
(rx/empty)))))