From e5314f4a137fdf38a1ede657b1865ecd270ac34a Mon Sep 17 00:00:00 2001 From: boskodev790 Date: Mon, 27 Apr 2026 03:17:00 -0500 Subject: [PATCH] :bug: Fix restore-version-from-plugin promise hanging on restore failure (#9111) Closes #9092. `restore-version-from-plugin` accepted `_reject` as a dead parameter and its stream had no `rx/catch`, so errors raised during the restore flow (failed `rp/cmd! :restore-file-snapshot`, persistence timeouts, or exceptions inside the watch body) silently swallowed instead of rejecting the plugin-facing promise at `file.cljs:81`. Plugin code that did `await version.restore()` would hang indefinitely on any failure. Wire `reject` through and wrap the emission with the same `rx/catch` pattern already used by `create-version-from-plugins` in this file. - Rename `_reject` to `reject` in the function signature - Wrap the `rx/concat` body with `rx/catch` that calls `(reject error)` and returns `rx/empty` on error, mirroring `create-version-from-plugins` - Add a CHANGES.md entry under the 2.17.0 Unreleased bugs-fixed section Signed-off-by: Andrey Antukh Co-authored-by: Andrey Antukh --- CHANGES.md | 1 + .../src/app/main/data/workspace/versions.cljs | 25 +++++++++++-------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 5482c07b95..4139644bf6 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -50,6 +50,7 @@ ### :bug: Bugs fixed +- Fix plugin API `fileVersion.restore()` promise hanging indefinitely on restore failure [Github #9092](https://github.com/penpot/penpot/issues/9092) - Fix LDAP provider params schema typo (`bind-passwor` → `bind-password`) introduced during the `clojure.spec` → `malli` migration; the schema slot now matches the runtime key actually read by `prepare-params` (`:password (:bind-password cfg)`) and `try-connectivity` (`(:bind-password cfg)`), so a wrong type for the password no longer slips through unvalidated - Fix `login-with-ldap` silently dropping its error message on the `ldap-not-initialized` restriction (typo `:hide` → `:hint`); the message `"ldap auth provider is not initialized"` now actually surfaces in logs and error responses instead of being discarded into an unread key - Fix `PENPOT_OIDC_USER_INFO_SOURCE` flag being silently ignored (`userinfo` / `token`) in the OIDC callback, causing "incomplete user info" failures during registration [Github #9108](https://github.com/penpot/penpot/issues/9108) diff --git a/frontend/src/app/main/data/workspace/versions.cljs b/frontend/src/app/main/data/workspace/versions.cljs index 072f8c634a..b942add4d8 100644 --- a/frontend/src/app/main/data/workspace/versions.cljs +++ b/frontend/src/app/main/data/workspace/versions.cljs @@ -359,23 +359,28 @@ (rx/empty)))))))) (defn restore-version-from-plugin - [file-id id resolve _reject] + [file-id id resolve reject] (assert (uuid? id) "expected valid uuid for `id`") (ptk/reify ::restore-version-from-plugins ptk/WatchEvent (watch [_ _ _] - (rx/concat - (rx/of (ev/event {::ev/name "restore-version" - ::ev/origin "plugins"}) - ::dwp/force-persist) + (->> (rx/concat + (rx/of (ev/event {::ev/name "restore-version" + ::ev/origin "plugins"}) + ::dwp/force-persist) - (->> (wait-for-persistence file-id id) - (rx/map #(initialize-version))) + (->> (wait-for-persistence file-id id) + (rx/map #(initialize-version))) - (->> (rx/of 1) - (rx/tap resolve) - (rx/ignore)))))) + (->> (rx/of 1) + (rx/tap resolve) + (rx/ignore))) + + ;; On error reject the promise and empty the stream + (rx/catch (fn [error] + (reject error) + (rx/empty)))))))