Code Monkey home page Code Monkey logo

Comments (4)

heejaechang avatar heejaechang commented on May 22, 2024 1

I am not like strongly against the cancellation exception. but I would normally expect cancellation exception from the cancellation token I gave in. if I get random cancellation exception, I will be like what did I cancel?

if I get like UnexcpectedDisconnectionException with message saying, someone Closed or Disposed JsonRpc/Underlying Stream while InvokeAsync is active, then it is more clear why the exception happened.

from vs-streamjsonrpc.

AArnott avatar AArnott commented on May 22, 2024

@heejaechang has this been a problem for you with Roslyn? Otherwise I may won't fix this.

from vs-streamjsonrpc.

heejaechang avatar heejaechang commented on May 22, 2024

@AArnott is there a specific reason why it chose to throw cancellation exception rather than explicit exception like unexpected disconnection or something like that?

from vs-streamjsonrpc.

AArnott avatar AArnott commented on May 22, 2024

A few reasons:

  1. It was the simplest approach: the only way the code had to interrupt the task we returned earlier is to cancel it.
  2. Given this is truly an exceptional situation, if we were to throw a novel exception type, we run the risk of the client not expecting to need to catch and deal with it. But it's quite likely they have a catch block around the call.
  3. Does the client really need to distinguish from all these events? Or ultimately will it handle them all the same? There already is a way for the client connection owner to receive an event about an unexpected connection closure, so that it could (for example) reconnect. But surely you wouldn't want every single outstanding request to receive an exception and each try to reestablish the connection at once.

That said, we do already define a RemoteRpcException base class, from which we could derive a more specific exception type. The client should (hopefully) already be prepared to catch this base exception type, so throwing a new derived type should have a relatively low risk.

from vs-streamjsonrpc.

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.