starpc 0.32.16 → 0.32.18

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.
@@ -1,4 +1,4 @@
1
- import type { MessageType } from '@aptre/protobuf-es-lite';
1
+ import type { MessageType } from "@aptre/protobuf-es-lite";
2
2
  export declare const protobufPackage = "e2e.mock";
3
3
  /**
4
4
  * MockMsg is the mock message body.
@@ -1,13 +1,14 @@
1
1
  // @generated by protoc-gen-es-lite unknown with parameter "target=ts,ts_nocheck=false"
2
- // @generated from file github.com/aperturerobotics/starpc/e2e/mock/mock.proto (package e2e.mock, syntax proto3)
2
+ // @generated from file github.com/aperturerobotics/starpc/mock/mock.proto (package e2e.mock, syntax proto3)
3
3
  /* eslint-disable */
4
- import { createMessageType, ScalarType } from '@aptre/protobuf-es-lite';
5
- export const protobufPackage = 'e2e.mock';
4
+ import { createMessageType, ScalarType } from "@aptre/protobuf-es-lite";
5
+ export const protobufPackage = "e2e.mock";
6
+ ;
6
7
  // MockMsg contains the message type declaration for MockMsg.
7
8
  export const MockMsg = createMessageType({
8
- typeName: 'e2e.mock.MockMsg',
9
+ typeName: "e2e.mock.MockMsg",
9
10
  fields: [
10
- { no: 1, name: 'body', kind: 'scalar', T: ScalarType.STRING },
11
+ { no: 1, name: "body", kind: "scalar", T: ScalarType.STRING },
11
12
  ],
12
13
  packedByDefault: true,
13
14
  });
@@ -1,6 +1,6 @@
1
- import { MockMsg } from './mock.pb.js';
2
- import { MethodKind } from '@aptre/protobuf-es-lite';
3
- import { ProtoRpc } from 'starpc';
1
+ import { MockMsg } from "./mock.pb.js";
2
+ import { MethodKind } from "@aptre/protobuf-es-lite";
3
+ import { ProtoRpc } from "starpc";
4
4
  /**
5
5
  * Mock service mocks some RPCs for the e2e tests.
6
6
  *
@@ -1,15 +1,15 @@
1
1
  // @generated by protoc-gen-es-starpc none with parameter "target=ts,ts_nocheck=false"
2
- // @generated from file github.com/aperturerobotics/starpc/e2e/mock/mock.proto (package e2e.mock, syntax proto3)
2
+ // @generated from file github.com/aperturerobotics/starpc/mock/mock.proto (package e2e.mock, syntax proto3)
3
3
  /* eslint-disable */
4
- import { MockMsg } from './mock.pb.js';
5
- import { MethodKind } from '@aptre/protobuf-es-lite';
4
+ import { MockMsg } from "./mock.pb.js";
5
+ import { MethodKind } from "@aptre/protobuf-es-lite";
6
6
  /**
7
7
  * Mock service mocks some RPCs for the e2e tests.
8
8
  *
9
9
  * @generated from service e2e.mock.Mock
10
10
  */
11
11
  export const MockDefinition = {
12
- typeName: 'e2e.mock.Mock',
12
+ typeName: "e2e.mock.Mock",
13
13
  methods: {
14
14
  /**
15
15
  * MockRequest runs a mock unary request.
@@ -17,12 +17,12 @@ export const MockDefinition = {
17
17
  * @generated from rpc e2e.mock.Mock.MockRequest
18
18
  */
19
19
  MockRequest: {
20
- name: 'MockRequest',
20
+ name: "MockRequest",
21
21
  I: MockMsg,
22
22
  O: MockMsg,
23
23
  kind: MethodKind.Unary,
24
24
  },
25
- },
25
+ }
26
26
  };
27
27
  export const MockServiceName = MockDefinition.typeName;
28
28
  export class MockClient {
@@ -1,5 +1,5 @@
1
1
  // Code generated by protoc-gen-srpc. DO NOT EDIT.
2
- // protoc-gen-srpc version: v0.32.12
2
+ // protoc-gen-srpc version: v0.32.15
3
3
  // source: github.com/aperturerobotics/starpc/echo/echo.proto
4
4
 
5
5
  package echo
package/go.mod CHANGED
@@ -13,11 +13,11 @@ replace nhooyr.io/websocket => github.com/paralin/nhooyr-websocket v1.8.12-0.202
13
13
 
14
14
  require (
15
15
  github.com/aperturerobotics/protobuf-go-lite v0.6.5 // latest
16
- github.com/aperturerobotics/util v1.23.8 // latest
16
+ github.com/aperturerobotics/util v1.23.10 // latest
17
17
  )
18
18
 
19
19
  require (
20
- github.com/libp2p/go-libp2p v0.35.1 // latest
20
+ github.com/libp2p/go-libp2p v0.35.3 // latest
21
21
  github.com/libp2p/go-yamux/v4 v4.0.2-0.20240322071716-53ef5820bd48 // master
22
22
  github.com/pkg/errors v0.9.1 // latest
23
23
  github.com/sirupsen/logrus v1.9.3 // latest
@@ -42,7 +42,7 @@ require (
42
42
  github.com/multiformats/go-varint v0.0.7 // indirect
43
43
  github.com/spaolacci/murmur3 v1.1.0 // indirect
44
44
  golang.org/x/crypto v0.19.0 // indirect
45
- golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 // indirect
45
+ golang.org/x/exp v0.0.0-20240707233637-46b078467d37 // indirect
46
46
  golang.org/x/sys v0.18.0 // indirect
47
47
  lukechampine.com/blake3 v1.2.1 // indirect
48
48
  )
package/go.sum CHANGED
@@ -4,8 +4,8 @@ github.com/aperturerobotics/json-iterator-lite v1.0.0 h1:cihbrYWoK/S2RYXhJLpDZd+
4
4
  github.com/aperturerobotics/json-iterator-lite v1.0.0/go.mod h1:snaApCEDtrHHP6UWSLKiYNOZU9A5NyzccKenx9oZEzg=
5
5
  github.com/aperturerobotics/protobuf-go-lite v0.6.5 h1:AuPPcZ7ZaJe9ZYYC4gF7/5/Xbn9Mt9uXyV3+ADWy+Ys=
6
6
  github.com/aperturerobotics/protobuf-go-lite v0.6.5/go.mod h1:YTbfnUj3feSULhs8VgepAHFnF3wUc0CPj4jd2axy21I=
7
- github.com/aperturerobotics/util v1.23.8 h1:hQGchdyAzLhhnBwE2MD4skAMsJf/bVcyxk1+OmA4wx0=
8
- github.com/aperturerobotics/util v1.23.8/go.mod h1:QsU/CKKewQCPqcB/FCM2JvkttO2DZramYWE1dgZObkw=
7
+ github.com/aperturerobotics/util v1.23.10 h1:igX3/8E6bCp9DSQApn+Kkz4MoltnsadiIgX2AWJ+mjM=
8
+ github.com/aperturerobotics/util v1.23.10/go.mod h1:QiSWcOha1HhCI4f48w6rd3gia9jIMGpfoeJiZMU+jLM=
9
9
  github.com/cloudflare/circl v1.3.8 h1:j+V8jJt09PoeMFIu2uh5JUyEaIHTXVOHslFoLNAKqwI=
10
10
  github.com/cloudflare/circl v1.3.8/go.mod h1:PDRU+oXvdD7KCtgKxW95M5Z8BpSCJXQORiZFnBQS5QU=
11
11
  github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
@@ -57,8 +57,8 @@ github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsT
57
57
  github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
58
58
  golang.org/x/crypto v0.19.0 h1:ENy+Az/9Y1vSrlrvBSyna3PITt4tiZLf7sgCjZBX7Wo=
59
59
  golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU=
60
- golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 h1:yixxcjnhBmY0nkL253HFVIm0JsFHwrHdT3Yh6szTnfY=
61
- golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8/go.mod h1:jj3sYF3dwk5D+ghuXyeI3r5MFf+NT2An6/9dOA95KSI=
60
+ golang.org/x/exp v0.0.0-20240707233637-46b078467d37 h1:uLDX+AfeFCct3a2C7uIWBKMJIR3CJMhcgfrUAqjRK6w=
61
+ golang.org/x/exp v0.0.0-20240707233637-46b078467d37/go.mod h1:M4RDyNAINzryxdtnbRXRL/OHtkFuWGRjvuhBJpk2IlY=
62
62
  golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
63
63
  golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
64
64
  golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4=
package/mock/mock.pb.go CHANGED
@@ -1,6 +1,6 @@
1
1
  // Code generated by protoc-gen-go-lite. DO NOT EDIT.
2
2
  // protoc-gen-go-lite version: v0.6.5
3
- // source: github.com/aperturerobotics/starpc/e2e/mock/mock.proto
3
+ // source: github.com/aperturerobotics/starpc/mock/mock.proto
4
4
 
5
5
  package e2e_mock
6
6
 
package/mock/mock.pb.ts CHANGED
@@ -1,11 +1,11 @@
1
1
  // @generated by protoc-gen-es-lite unknown with parameter "target=ts,ts_nocheck=false"
2
- // @generated from file github.com/aperturerobotics/starpc/e2e/mock/mock.proto (package e2e.mock, syntax proto3)
2
+ // @generated from file github.com/aperturerobotics/starpc/mock/mock.proto (package e2e.mock, syntax proto3)
3
3
  /* eslint-disable */
4
4
 
5
- import type { MessageType, PartialFieldInfo } from '@aptre/protobuf-es-lite'
6
- import { createMessageType, ScalarType } from '@aptre/protobuf-es-lite'
5
+ import type { MessageType, PartialFieldInfo } from "@aptre/protobuf-es-lite";
6
+ import { createMessageType, ScalarType } from "@aptre/protobuf-es-lite";
7
7
 
8
- export const protobufPackage = 'e2e.mock'
8
+ export const protobufPackage = "e2e.mock";
9
9
 
10
10
  /**
11
11
  * MockMsg is the mock message body.
@@ -16,14 +16,16 @@ export interface MockMsg {
16
16
  /**
17
17
  * @generated from field: string body = 1;
18
18
  */
19
- body?: string
20
- }
19
+ body?: string;
20
+
21
+ };
21
22
 
22
23
  // MockMsg contains the message type declaration for MockMsg.
23
24
  export const MockMsg: MessageType<MockMsg> = createMessageType({
24
- typeName: 'e2e.mock.MockMsg',
25
- fields: [
26
- { no: 1, name: 'body', kind: 'scalar', T: ScalarType.STRING },
27
- ] as readonly PartialFieldInfo[],
28
- packedByDefault: true,
29
- })
25
+ typeName: "e2e.mock.MockMsg",
26
+ fields: [
27
+ { no: 1, name: "body", kind: "scalar", T: ScalarType.STRING },
28
+ ] as readonly PartialFieldInfo[],
29
+ packedByDefault: true,
30
+ });
31
+
@@ -1,6 +1,6 @@
1
1
  // Code generated by protoc-gen-srpc. DO NOT EDIT.
2
- // protoc-gen-srpc version: v0.32.12
3
- // source: github.com/aperturerobotics/starpc/e2e/mock/mock.proto
2
+ // protoc-gen-srpc version: v0.32.15
3
+ // source: github.com/aperturerobotics/starpc/mock/mock.proto
4
4
 
5
5
  package e2e_mock
6
6
 
@@ -1,10 +1,10 @@
1
1
  // @generated by protoc-gen-es-starpc none with parameter "target=ts,ts_nocheck=false"
2
- // @generated from file github.com/aperturerobotics/starpc/e2e/mock/mock.proto (package e2e.mock, syntax proto3)
2
+ // @generated from file github.com/aperturerobotics/starpc/mock/mock.proto (package e2e.mock, syntax proto3)
3
3
  /* eslint-disable */
4
4
 
5
- import { MockMsg } from './mock.pb.js'
6
- import { MethodKind } from '@aptre/protobuf-es-lite'
7
- import { ProtoRpc } from 'starpc'
5
+ import { MockMsg } from "./mock.pb.js";
6
+ import { MethodKind } from "@aptre/protobuf-es-lite";
7
+ import { ProtoRpc } from "starpc";
8
8
 
9
9
  /**
10
10
  * Mock service mocks some RPCs for the e2e tests.
@@ -12,7 +12,7 @@ import { ProtoRpc } from 'starpc'
12
12
  * @generated from service e2e.mock.Mock
13
13
  */
14
14
  export const MockDefinition = {
15
- typeName: 'e2e.mock.Mock',
15
+ typeName: "e2e.mock.Mock",
16
16
  methods: {
17
17
  /**
18
18
  * MockRequest runs a mock unary request.
@@ -20,13 +20,13 @@ export const MockDefinition = {
20
20
  * @generated from rpc e2e.mock.Mock.MockRequest
21
21
  */
22
22
  MockRequest: {
23
- name: 'MockRequest',
23
+ name: "MockRequest",
24
24
  I: MockMsg,
25
25
  O: MockMsg,
26
26
  kind: MethodKind.Unary,
27
27
  },
28
- },
29
- } as const
28
+ }
29
+ } as const;
30
30
 
31
31
  /**
32
32
  * Mock service mocks some RPCs for the e2e tests.
@@ -39,7 +39,11 @@ export interface Mock {
39
39
  *
40
40
  * @generated from rpc e2e.mock.Mock.MockRequest
41
41
  */
42
- MockRequest(request: MockMsg, abortSignal?: AbortSignal): Promise<MockMsg>
42
+ MockRequest(
43
+ request: MockMsg, abortSignal?: AbortSignal
44
+ ):
45
+ Promise<MockMsg>
46
+
43
47
  }
44
48
 
45
49
  export const MockServiceName = MockDefinition.typeName
@@ -58,9 +62,9 @@ export class MockClient implements Mock {
58
62
  * @generated from rpc e2e.mock.Mock.MockRequest
59
63
  */
60
64
  async MockRequest(
61
- request: MockMsg,
62
- abortSignal?: AbortSignal,
63
- ): Promise<MockMsg> {
65
+ request: MockMsg, abortSignal?: AbortSignal
66
+ ):
67
+ Promise<MockMsg> {
64
68
  const requestMsg = MockMsg.create(request)
65
69
  const result = await this.rpc.request(
66
70
  this.service,
@@ -70,4 +74,5 @@ export class MockClient implements Mock {
70
74
  )
71
75
  return MockMsg.fromBinary(result)
72
76
  }
77
+
73
78
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "starpc",
3
- "version": "0.32.16",
3
+ "version": "0.32.18",
4
4
  "description": "Streaming protobuf RPC service protocol over any two-way channel.",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -92,10 +92,10 @@
92
92
  "lint-staged": "^15.2.2",
93
93
  "pre-commit": "^1.2.2",
94
94
  "prettier": "^3.2.4",
95
- "rimraf": "^5.0.7",
95
+ "rimraf": "^6.0.1",
96
96
  "tsx": "^4.15.7",
97
97
  "typescript": "^5.5.2",
98
- "vitest": "^1.6.0"
98
+ "vitest": "^2.0.2"
99
99
  },
100
100
  "dependencies": {
101
101
  "@aptre/it-ws": "^1.0.1",
@@ -26,12 +26,12 @@ func NewClientRPC(ctx context.Context, service, method string) *ClientRPC {
26
26
  // Start sets the writer and writes the MsgSend message.
27
27
  // must only be called once!
28
28
  func (r *ClientRPC) Start(writer PacketWriter, writeFirstMsg bool, firstMsg []byte) error {
29
- select {
30
- case <-r.ctx.Done():
29
+ if err := r.ctx.Err(); err != nil {
31
30
  r.ctxCancel()
31
+ _ = writer.Close()
32
32
  return context.Canceled
33
- default:
34
33
  }
34
+
35
35
  r.mtx.Lock()
36
36
  defer r.mtx.Unlock()
37
37
  defer r.bcast.Broadcast()
@@ -75,6 +75,12 @@ func NewOpenStreamWithMuxedConn(conn network.MuxedConn) OpenStreamFunc {
75
75
  return func(ctx context.Context, msgHandler PacketDataHandler, closeHandler CloseHandler) (PacketWriter, error) {
76
76
  mstrm, err := conn.OpenStream(ctx)
77
77
  if err != nil {
78
+ // If the error is a timeout, context may be canceled.
79
+ // Prefer the context canceled error (yamux returns timeout for context cancel.)
80
+ timeoutErr, ok := err.(interface{ Timeout() bool })
81
+ if ok && timeoutErr.Timeout() && ctx.Err() != nil {
82
+ return nil, context.Canceled
83
+ }
78
84
  return nil, err
79
85
  }
80
86
  rw := NewPacketReadWriter(mstrm)