Skip to content

Commit

Permalink
fix(rpc): maintain strictSerialization option also in new observables
Browse files Browse the repository at this point in the history
  • Loading branch information
marcj committed Mar 5, 2024
1 parent 16f0c1d commit 273330b
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/rpc/src/server/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,8 @@ export class RpcServerAction {
case RpcTypes.ActionObservableSubscribe: {
const observable = this.observables[message.id];
if (!observable) return response.error(new Error('No observable found'));
response.strictSerialization = observable.types.strictSerialization;

const { types, classType, method } = observable;
const body = message.parseBody<rpcActionObservableSubscribeId>();
if (observable.subscriptions[body.id]) return response.error(new Error('Subscription already created'));
Expand All @@ -340,6 +342,7 @@ export class RpcServerAction {
};
observable.subscriptions[body.id] = sub;

response.errorLabel = `Observable ${getClassName(observable.classType)}.${observable.method} next serialization error`;
sub.sub = observable.observable.subscribe((next) => {
if (!sub.active) return;
response.reply(RpcTypes.ResponseActionObservableNext, {
Expand Down Expand Up @@ -414,6 +417,7 @@ export class RpcServerAction {
case RpcTypes.ActionObservableProgressNext: { //ProgressTracker changes from client (e.g. stop signal)
const observable = this.observables[message.id];
if (!observable || !(observable.observable instanceof ProgressTracker)) return response.error(new Error('No observable ProgressTracker to sync found'));
response.strictSerialization = observable.types.strictSerialization;
observable.observable.next(message.parseBody<ProgressTrackerState[]>());
break;
}
Expand Down

0 comments on commit 273330b

Please sign in to comment.