starpc 0.49.7 → 0.49.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/srpc/common-rpc.js +2 -2
- package/dist/srpc/errors.d.ts +6 -0
- package/dist/srpc/errors.js +14 -0
- package/go.mod +2 -2
- package/go.sum +4 -8
- package/package.json +2 -2
- package/srpc/common-rpc.ts +4 -2
- package/srpc/errors.ts +16 -0
- package/srpc/packet-rw.go +1 -1
package/dist/srpc/common-rpc.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { pushable } from 'it-pushable';
|
|
2
2
|
import { Packet } from './rpcproto.pb.js';
|
|
3
|
-
import { ERR_RPC_ABORT } from './errors.js';
|
|
3
|
+
import { ERR_RPC_ABORT, RemoteRPCError } from './errors.js';
|
|
4
4
|
// CommonRPC is common logic between server and client RPCs.
|
|
5
5
|
export class CommonRPC {
|
|
6
6
|
// sink is the data sink for incoming messages.
|
|
@@ -131,7 +131,7 @@ export class CommonRPC {
|
|
|
131
131
|
}
|
|
132
132
|
this.pushRpcData(packet.data, packet.dataIsZero);
|
|
133
133
|
if (packet.error) {
|
|
134
|
-
this._rpcDataSource.end(new
|
|
134
|
+
this._rpcDataSource.end(new RemoteRPCError(this.service, this.method, packet.error));
|
|
135
135
|
}
|
|
136
136
|
else if (packet.complete) {
|
|
137
137
|
this._rpcDataSource.end();
|
package/dist/srpc/errors.d.ts
CHANGED
|
@@ -2,4 +2,10 @@ export declare const ERR_RPC_ABORT = "ERR_RPC_ABORT";
|
|
|
2
2
|
export declare function isAbortError(err: unknown): boolean;
|
|
3
3
|
export declare const ERR_STREAM_IDLE = "ERR_STREAM_IDLE";
|
|
4
4
|
export declare function isStreamIdleError(err: unknown): boolean;
|
|
5
|
+
export declare class RemoteRPCError extends Error {
|
|
6
|
+
readonly rpcService: string;
|
|
7
|
+
readonly rpcMethod: string;
|
|
8
|
+
readonly rpcError: string;
|
|
9
|
+
constructor(rpcService: string, rpcMethod: string, rpcError: string);
|
|
10
|
+
}
|
|
5
11
|
export declare function castToError(err: any, defaultMsg?: string): Error;
|
package/dist/srpc/errors.js
CHANGED
|
@@ -18,6 +18,20 @@ export function isStreamIdleError(err) {
|
|
|
18
18
|
const message = err.message;
|
|
19
19
|
return message === ERR_STREAM_IDLE;
|
|
20
20
|
}
|
|
21
|
+
// RemoteRPCError is returned when the remote peer completes an RPC with an
|
|
22
|
+
// error response.
|
|
23
|
+
export class RemoteRPCError extends Error {
|
|
24
|
+
rpcService;
|
|
25
|
+
rpcMethod;
|
|
26
|
+
rpcError;
|
|
27
|
+
constructor(rpcService, rpcMethod, rpcError) {
|
|
28
|
+
super(rpcError);
|
|
29
|
+
this.name = 'RemoteRPCError';
|
|
30
|
+
this.rpcService = rpcService;
|
|
31
|
+
this.rpcMethod = rpcMethod;
|
|
32
|
+
this.rpcError = rpcError;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
21
35
|
// castToError casts an object to an Error.
|
|
22
36
|
// if err is a string, uses it as the message.
|
|
23
37
|
// if err is undefined, returns new Error(defaultMsg)
|
package/go.mod
CHANGED
|
@@ -3,7 +3,7 @@ module github.com/aperturerobotics/starpc
|
|
|
3
3
|
go 1.25.0
|
|
4
4
|
|
|
5
5
|
require (
|
|
6
|
-
github.com/aperturerobotics/common v0.
|
|
6
|
+
github.com/aperturerobotics/common v0.33.0 // latest
|
|
7
7
|
github.com/aperturerobotics/protobuf-go-lite v0.13.0 // latest
|
|
8
8
|
github.com/aperturerobotics/util v1.34.3 // latest
|
|
9
9
|
)
|
|
@@ -21,7 +21,7 @@ require (
|
|
|
21
21
|
require (
|
|
22
22
|
github.com/libp2p/go-yamux/v4 v4.0.2 // latest
|
|
23
23
|
github.com/pkg/errors v0.9.1 // latest
|
|
24
|
-
github.com/sirupsen/logrus v1.9.5-0.
|
|
24
|
+
github.com/sirupsen/logrus v1.9.5-0.20260426203557-6878cb36b029 // latest
|
|
25
25
|
)
|
|
26
26
|
|
|
27
27
|
require (
|
package/go.sum
CHANGED
|
@@ -2,8 +2,8 @@ github.com/aperturerobotics/abseil-cpp v0.0.0-20260131110040-4bb56e2f9017 h1:3U7
|
|
|
2
2
|
github.com/aperturerobotics/abseil-cpp v0.0.0-20260131110040-4bb56e2f9017/go.mod h1:lNSJTKECIUFAnfeSqy01kXYTYe1BHubW7198jNX3nEw=
|
|
3
3
|
github.com/aperturerobotics/cli v1.1.0 h1:7a+YRC+EY3npAnTzhHV5gLCiw91KS0Ts3XwLILGOsT8=
|
|
4
4
|
github.com/aperturerobotics/cli v1.1.0/go.mod h1:M7BFP9wow5ytTzMyJQOOO991fGfsUqdTI7gGEsHfTQ8=
|
|
5
|
-
github.com/aperturerobotics/common v0.
|
|
6
|
-
github.com/aperturerobotics/common v0.
|
|
5
|
+
github.com/aperturerobotics/common v0.33.0 h1:IheETbaQPmvUpkm6Z+/1jbuAQOXZF5REnRRMXTaIeVk=
|
|
6
|
+
github.com/aperturerobotics/common v0.33.0/go.mod h1:xabIJydWovkzjs5YZD8ru/BgFTAXekgHwV8DrTl3R2w=
|
|
7
7
|
github.com/aperturerobotics/go-protoc-gen-prost v0.0.0-20260329113538-218ccd8f20e0 h1:6/3RSSlPEQ6LeidslB1ZCJkxW+MnfYDkvdWMDklDXw4=
|
|
8
8
|
github.com/aperturerobotics/go-protoc-gen-prost v0.0.0-20260329113538-218ccd8f20e0/go.mod h1:OBb/beWmr/pDIZAUfi86j/4tBh2v5ctTxKMqSnh9c/4=
|
|
9
9
|
github.com/aperturerobotics/go-protoc-wasi v0.0.0-20260329113540-600516012db3 h1:lp+V8RYcBwTX1p81swkpZn5fhw1wn2xLorzETIxRyZQ=
|
|
@@ -16,8 +16,6 @@ github.com/aperturerobotics/protobuf v0.0.0-20260203024654-8201686529c4 h1:4Dy3B
|
|
|
16
16
|
github.com/aperturerobotics/protobuf v0.0.0-20260203024654-8201686529c4/go.mod h1:tMgO7y6SJo/d9ZcvrpNqIQtdYT9de+QmYaHOZ4KnhOg=
|
|
17
17
|
github.com/aperturerobotics/protobuf-go-lite v0.13.0 h1:jEvCJhHaJEikDY/va2AUnS0DOb/0n82aISLAqxSh4Sk=
|
|
18
18
|
github.com/aperturerobotics/protobuf-go-lite v0.13.0/go.mod h1:lGH3s5ArCTXKI4wJdlNpaybUtwSjfAG0vdWjxOfMcF8=
|
|
19
|
-
github.com/aperturerobotics/util v1.33.0 h1:l7Aql7rlFZaGPRS+lzFC7h0zuLE0WyR3nPVXgCYMW88=
|
|
20
|
-
github.com/aperturerobotics/util v1.33.0/go.mod h1:FOKm51ZpgLsRszA4e7mjvqrt6J6Pju5GjSJg1Qz4Ouo=
|
|
21
19
|
github.com/aperturerobotics/util v1.34.3 h1:9lFYJovGlAHYX66aWKVzfoVzYox13P054d/Dy8T/GRg=
|
|
22
20
|
github.com/aperturerobotics/util v1.34.3/go.mod h1:xtE2hwpgKGaW0TLx01+9xLsG+rYvhygQ+JCuQeAbvME=
|
|
23
21
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
|
@@ -32,8 +30,8 @@ github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
|
|
32
30
|
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
|
33
31
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
|
34
32
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
|
35
|
-
github.com/sirupsen/logrus v1.9.5-0.
|
|
36
|
-
github.com/sirupsen/logrus v1.9.5-0.
|
|
33
|
+
github.com/sirupsen/logrus v1.9.5-0.20260426203557-6878cb36b029 h1:24s81vaIm1uch3GUIIZxneOyFRfBbHRdymMRBdoDuk0=
|
|
34
|
+
github.com/sirupsen/logrus v1.9.5-0.20260426203557-6878cb36b029/go.mod h1:FXZFonkDAnFozmO+5hGAFvB0Yg9/j2SIhA/QuIkP180=
|
|
37
35
|
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
|
|
38
36
|
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
|
|
39
37
|
github.com/tetratelabs/wazero v1.11.0 h1:+gKemEuKCTevU4d7ZTzlsvgd1uaToIDtlQlmNbwqYhA=
|
|
@@ -42,8 +40,6 @@ github.com/xrash/smetrics v0.0.0-20250705151800-55b8f293f342 h1:FnBeRrxr7OU4VvAz
|
|
|
42
40
|
github.com/xrash/smetrics v0.0.0-20250705151800-55b8f293f342/go.mod h1:Ohn+xnUBiLI6FVj/9LpzZWtj1/D6lUovWYBkxHVV3aM=
|
|
43
41
|
golang.org/x/mod v0.35.0 h1:Ww1D637e6Pg+Zb2KrWfHQUnH2dQRLBQyAtpr/haaJeM=
|
|
44
42
|
golang.org/x/mod v0.35.0/go.mod h1:+GwiRhIInF8wPm+4AoT6L0FA1QWAad3OMdTRx4tFYlU=
|
|
45
|
-
golang.org/x/sys v0.42.0 h1:omrd2nAlyT5ESRdCLYdm3+fMfNFE/+Rf4bDIQImRJeo=
|
|
46
|
-
golang.org/x/sys v0.42.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
|
|
47
43
|
golang.org/x/sys v0.43.0 h1:Rlag2XtaFTxp19wS8MXlJwTvoh8ArU6ezoyFsMyCTNI=
|
|
48
44
|
golang.org/x/sys v0.43.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
|
|
49
45
|
google.golang.org/protobuf v1.36.11 h1:fV6ZwhNocDyBLK0dj+fg8ektcVegBBuEolpbTQyBNVE=
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "starpc",
|
|
3
|
-
"version": "0.49.
|
|
3
|
+
"version": "0.49.8",
|
|
4
4
|
"description": "Streaming protobuf RPC service protocol over any two-way channel.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -119,7 +119,7 @@
|
|
|
119
119
|
"globals": "^17.5.0",
|
|
120
120
|
"happy-dom": "^20.9.0",
|
|
121
121
|
"husky": "^9.1.7",
|
|
122
|
-
"lint-staged": "^
|
|
122
|
+
"lint-staged": "^17.0.0",
|
|
123
123
|
"prettier": "^3.8.3",
|
|
124
124
|
"rimraf": "^6.1.3",
|
|
125
125
|
"tsx": "^4.20.4",
|
package/srpc/common-rpc.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { CompleteMessage } from '@aptre/protobuf-es-lite'
|
|
|
4
4
|
|
|
5
5
|
import type { CallData, CallStart } from './rpcproto.pb.js'
|
|
6
6
|
import { Packet } from './rpcproto.pb.js'
|
|
7
|
-
import { ERR_RPC_ABORT } from './errors.js'
|
|
7
|
+
import { ERR_RPC_ABORT, RemoteRPCError } from './errors.js'
|
|
8
8
|
|
|
9
9
|
// CommonRPC is common logic between server and client RPCs.
|
|
10
10
|
export class CommonRPC {
|
|
@@ -158,7 +158,9 @@ export class CommonRPC {
|
|
|
158
158
|
|
|
159
159
|
this.pushRpcData(packet.data, packet.dataIsZero)
|
|
160
160
|
if (packet.error) {
|
|
161
|
-
this._rpcDataSource.end(
|
|
161
|
+
this._rpcDataSource.end(
|
|
162
|
+
new RemoteRPCError(this.service, this.method, packet.error),
|
|
163
|
+
)
|
|
162
164
|
} else if (packet.complete) {
|
|
163
165
|
this._rpcDataSource.end()
|
|
164
166
|
}
|
package/srpc/errors.ts
CHANGED
|
@@ -22,6 +22,22 @@ export function isStreamIdleError(err: unknown): boolean {
|
|
|
22
22
|
return message === ERR_STREAM_IDLE
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
+
// RemoteRPCError is returned when the remote peer completes an RPC with an
|
|
26
|
+
// error response.
|
|
27
|
+
export class RemoteRPCError extends Error {
|
|
28
|
+
public readonly rpcService: string
|
|
29
|
+
public readonly rpcMethod: string
|
|
30
|
+
public readonly rpcError: string
|
|
31
|
+
|
|
32
|
+
constructor(rpcService: string, rpcMethod: string, rpcError: string) {
|
|
33
|
+
super(rpcError)
|
|
34
|
+
this.name = 'RemoteRPCError'
|
|
35
|
+
this.rpcService = rpcService
|
|
36
|
+
this.rpcMethod = rpcMethod
|
|
37
|
+
this.rpcError = rpcError
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
25
41
|
// castToError casts an object to an Error.
|
|
26
42
|
// if err is a string, uses it as the message.
|
|
27
43
|
// if err is undefined, returns new Error(defaultMsg)
|
package/srpc/packet-rw.go
CHANGED
|
@@ -45,7 +45,7 @@ func (r *PacketReadWriter) WritePacket(p *Packet) error {
|
|
|
45
45
|
msgSize := p.SizeVT()
|
|
46
46
|
|
|
47
47
|
// G115: integer overflow conversion int -> uint32 (gosec)
|
|
48
|
-
if msgSize > math.MaxUint32 {
|
|
48
|
+
if uint64(msgSize) > uint64(math.MaxUint32) {
|
|
49
49
|
return errors.New("message size exceeds maximum uint32 value")
|
|
50
50
|
}
|
|
51
51
|
|