Skip to content

Commit

Permalink
Clone the tshd gRPC client to allow inspecting errors (#39229)
Browse files Browse the repository at this point in the history
* Add functions to clone every gRPC method, so they can be passed over the context bridge

* Replace `@grpc/grpc-js` interceptors with `@protobuf-ts/runtime-rpc` ones

* Replace string check with check on metadata, add missing `AddMetadataToRetryableError`

* Add `pin` to sensitive properties

It's needed because now we also log a passwordless login stream call.

* Add `cloneClient` method to clone the entire gRPC client

* Switch tests to `TshdRetryableError`

* Improve comments

* Move `cloneClient` and `cloneAbortSignal` to the top of the file

* Simplify condition

* Lowercase logs

* Check if the error is `RpcError` using `instanceof`

* Log error object instead of `[object Object]`

* Do not export call specific types

* Wrap gRPC calls in `createClient` to allow passing the errors over the context bridge (#39230)

* Regenerate protos with the `protobuf-ts` client

* Enable `strictBindCallApply` so `.bind()` results have correct types (instead of `any`)

This is needed for wrapping calls in `createClient`.

* Use `protobuf-ts` client instead of `grpc-js` one

* Convert `createClient` to use `protobuf-ts` response style, clone each call

* Switch callsites to `cloneAbortSignal`

* Replace `error.message` checks with a proper check on the error status code

* Clone the entire client instead of each method separately

* Correct the error `cause` in `ResourceSearchError`

* Remove `params.sortBy` defaults, always set `startKey` to string

* Use a simpler type for `reportUsageEvent`

* Fix interceptor test

* Ignore TS error in `highbar.ts`
  • Loading branch information
gzdunek committed Mar 18, 2024
1 parent 49ac0c5 commit 784d7ac
Show file tree
Hide file tree
Showing 109 changed files with 3,352 additions and 3,828 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Expand Up @@ -8,3 +8,4 @@ docs/theme/js/theme.js linguist-vendored=false
*_pb.d.ts linguist-generated
*_pb.ts linguist-generated
*_pb.grpc-*.ts linguist-generated
*_pb.client.ts linguist-generated
26 changes: 13 additions & 13 deletions buf-ts.gen.yaml
@@ -1,13 +1,13 @@
version: v1
plugins:
- name: typescript
out: gen/proto/ts
opt: long_type_number,eslint_disable,add_pb_suffix,client_grpc1,server_grpc1,ts_nocheck
path:
- npm
- exec
- --yes
- --package=@protobuf-ts/plugin@2.9.3
- --
- protoc-gen-ts
strategy: all
version: v1
plugins:
- name: typescript
out: gen/proto/ts
opt: long_type_number,eslint_disable,add_pb_suffix,server_grpc1,ts_nocheck
path:
- npm
- exec
- --yes
- --package=@protobuf-ts/plugin@2.9.3
- --
- protoc-gen-ts
strategy: all
2 changes: 1 addition & 1 deletion gen/proto/ts/google/protobuf/descriptor_pb.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion gen/proto/ts/google/protobuf/duration_pb.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion gen/proto/ts/google/protobuf/empty_pb.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion gen/proto/ts/google/protobuf/field_mask_pb.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion gen/proto/ts/google/protobuf/timestamp_pb.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion gen/proto/ts/prehog/v1/teleport_pb.grpc-server.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion gen/proto/ts/prehog/v1/teleport_pb.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

57 changes: 57 additions & 0 deletions gen/proto/ts/prehog/v1alpha/connect_pb.client.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

58 changes: 0 additions & 58 deletions gen/proto/ts/prehog/v1alpha/connect_pb.grpc-client.ts

This file was deleted.

2 changes: 1 addition & 1 deletion gen/proto/ts/prehog/v1alpha/connect_pb.grpc-server.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion gen/proto/ts/prehog/v1alpha/connect_pb.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

57 changes: 57 additions & 0 deletions gen/proto/ts/prehog/v1alpha/tbot_pb.client.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 784d7ac

Please sign in to comment.