Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attaching p/catch after p/finally is ineffective #143

Open
DerGuteMoritz opened this issue Nov 9, 2023 · 1 comment
Open

Attaching p/catch after p/finally is ineffective #143

DerGuteMoritz opened this issue Nov 9, 2023 · 1 comment

Comments

@DerGuteMoritz
Copy link

When attaching a p/catch handler to a promise after a p/finally handler, it is rendered ineffective. Example:

(let [p (p/deferred)
      f (p/finally p #(prn :finally))
      c (p/catch p identity)]
  (p/reject! p :boom)
  (p/handle c prn))

;; output:
:finally
nil :boom

As you can see, c was (erroneously) rejected. This doesn't happen when swapping the handler attachments:

(let [p (p/deferred)
      c (p/catch p identity)
      f (p/finally p #(prn :finally))]
  (p/reject! p :boom)
  (p/handle c prn))

;; output:
:finally
:boom nil

It also breaks when attaching the p/catch to the promise returned by p/finally:

(let [p (p/deferred)
      f (p/finally p #(prn :finally))
      c (p/catch f identity)]
  (p/reject! p :boom)
  (p/handle c prn))

;; output:
:finally
nil :boom

And it also works when attaching the p/finally to the promise returned by p/catch:

(let [p (p/deferred)
      c (p/catch p identity)
      f (p/finally c #(prn :finally))]
  (p/reject! p :boom)
  (p/handle c prn))

;; output:
:finally
:boom nil

This relates to version 11.0.678. It still used to work as expected with version 8.0.450 (though I haven't tried any in between versions).

Hope that makes sense!

@DerGuteMoritz
Copy link
Author

Ah and this is using ClojureScript.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant