rsocket / rsocket-js

JavaScript implementation of RSocket
https://github.com/rsocket/rsocket-js
Apache License 2.0
594 stars 97 forks source link

Add support for throwing errors with custom error code #272

Closed palamccc closed 6 months ago

palamccc commented 6 months ago

Motivation:

In the rsocket-js implementation (v0 branch), all stream errors are serialized and transmitted to other end with fixed error code. Due to this bug, there is no way to send custom error codes over stream (Bug report https://github.com/rsocket/rsocket-js/issues/218)

Custom error codes are supported in the rsocket protocol and implemented in rsocket-java this using RSocketErrorException . When the application throws RSocketErrorExecption, the error code of the exception is sent over the stream. But this feature is not implemented in rsocket-js.

Modifications:

Result:

This will allow application to send custom error codes to other party.

viglucci commented 6 months ago

Hey @palamccc thanks for the contribution!

Would you be able to add tests for your changes? Looks like RSocketServer-test.js might have good examples to build off of.

https://github.com/rsocket/rsocket-js/blob/master/packages/rsocket-core/src/__tests__/RSocketServer-test.js#L144-L151

Additionally the DCO check will ideally need to be resolved before this can be merged.

palamccc commented 6 months ago

Would you be able to add tests for your changes? Looks like RSocketServer-test.js might have good examples to build off of.

@viglucci I've added tests now.

viglucci commented 6 months ago

LGTM. Thanks! I'll LYK when a new version is published.

palamccc commented 6 months ago

I've contributed types to DefinitelyTyped https://github.com/DefinitelyTyped/DefinitelyTyped/pull/68788 Waiting for 0.0.28 release :-).

viglucci commented 6 months ago

@palamccc I've published a new version which should include this change. If you would be so kind, please validate this change with rsocket-core@0.0.29-alpha.0.