Skip to content

Commit

Permalink
fix(srpc): ts: catch error in invokefn
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Stewart <christian@paral.in>
  • Loading branch information
paralin committed Dec 4, 2022
1 parent 65ab343 commit fefdae7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "starpc",
"version": "0.15.3",
"version": "0.15.4",
"description": "Streaming protobuf RPC service protocol over any two-way channel.",
"license": "MIT",
"author": {
Expand Down
10 changes: 6 additions & 4 deletions srpc/server-rpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,13 @@ export class ServerRPC extends CommonRPC {
}

// invokeRPC starts invoking the RPC handler.
private invokeRPC(invokeFn: InvokeFn) {
private async invokeRPC(invokeFn: InvokeFn) {
const dataSink = this._createDataSink()
invokeFn(this.rpcDataSource, dataSink).catch((err) => {
this.close(err)
})
try {
await invokeFn(this.rpcDataSource, dataSink)
} catch (err) {
this.close(err as Error)
}
}

// _createDataSink creates a sink for outgoing data packets.
Expand Down

0 comments on commit fefdae7

Please sign in to comment.