Skip to content
This repository was archived by the owner on Apr 8, 2020. It is now read-only.
This repository was archived by the owner on Apr 8, 2020. It is now read-only.

When returning a binary stream, Socket hosting model's error handling isn't consistent with Http hosting model's #163

Closed
@SteveSandersonMS

Description

@SteveSandersonMS

Both hosting models handle errors consistently and correctly for non-Stream responses.

But for Stream responses, if the invoked Node module throws an uncaught exception,

  • The Http hosting model handles it well, behaving the same as if you invoked callback(error, null) and ends up throwing an exception back in .NET land containing the error info
  • The Socket hosting model doesn't handle it well. It calls connection.end(errorInfoAsJson), but when this string gets back into .NET land, it just becomes the content of the result stream. It doesn't throw an exception like you'd expect.

This is because the Socket hosting model, when you return a binary string, just literally passes the binary data back to .NET without any encoding/prefix/suffix, so it doesn't even have a way to signal to .NET that the response for a given call should be regarded as an error. To solve this, consider adding a short prefix before the Stream-type responses that specifies whether the remaining data in the stream should be regarded as the success-case binary data, or a JSON string describing an exception to be thrown.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions