Git Product home page Git Product logo

Comments (2)

jponge avatar jponge commented on May 24, 2024

What you see might be counter intuitive at first, but it's working as intended 😃

I hope the explanations below will help you.

Case 1

This is expected, see the implementation of a Uni from a known value: https://github.com/smallrye/smallrye-mutiny/blob/main/implementation/src/main/java/io/smallrye/mutiny/operators/uni/builders/UniCreateFromKnownItem.java#L35

If the cancellation arrives soon enough, then no item is ever emitted due to a cancellation check in the forward method.
The .await().indefinitely() operator never receives an item, hence it hangs forever.

Remember that cancellation is a signal sent to the operators above, not the operators below.

Case 2

.subscribe().with() is not blocking, so a subscription request is sent to the operators above. Since that's an immediate Uni there are only good reasons for it to reach the operators below.

Indeed a cancellation signal is an eventual cancellation, not an immediate one, see Rule 1.8 of the Reactive Streams protocol.

More generally for cancellation to work you need an initial publisher that's properly dealing with cancellation. Still, cancellation may not always work because of timing issues (e.g., the item is sent fast enough before the cancellation request has been propagated).

from smallrye-mutiny.

manofthepeace avatar manofthepeace commented on May 24, 2024

Thanks so much for your explanations and taking the time. As usual, super detailed and helpful.

Remember that cancellation is a signal sent to the operators above, not the operators below.

I don't know why I keep forgetting that. I don't know why but I still feel this is "somewhat" dangerous. I feel like a sort of checked exception in that case could make sense if you await and what you are awaiting on gets cancelled, but definitely does not play nice with the whole reactive universe.

For case 2 I do understand. I do understand that .subscribe().with() is non blocking, but there's something in me that thought that the onSubscribtion().invoke() would actually block the subscription. i.e. the operation would happen after the onSubscription event.

from smallrye-mutiny.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.