Skip to content

Commit

Permalink
V2: Update dependencies (#1239)
Browse files Browse the repository at this point in the history
Signed-off-by: Timo Stamm <ts@timostamm.de>
  • Loading branch information
timostamm authored Sep 19, 2024
1 parent 25ca96e commit fe5e10d
Show file tree
Hide file tree
Showing 62 changed files with 179 additions and 176 deletions.
61 changes: 33 additions & 28 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion packages/connect-cloudflare/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"lint": "eslint --max-warnings 0 ."
},
"dependencies": {
"@bufbuild/protobuf": "^2.0.0",
"@bufbuild/protobuf": "^2.1.0",
"@connectrpc/connect": "2.0.0-alpha.1",
"@connectrpc/connect-node": "2.0.0-alpha.1"
},
Expand Down
4 changes: 2 additions & 2 deletions packages/connect-conformance/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@
"attw": "attw --pack"
},
"dependencies": {
"@bufbuild/protobuf": "^2.0.0",
"@bufbuild/protobuf": "^2.1.0",
"@connectrpc/connect": "2.0.0-alpha.1",
"fflate": "^0.8.1",
"tar-stream": "^3.1.7"
},
"devDependencies": {
"@bufbuild/buf": "^1.39.0",
"@bufbuild/protoc-gen-es": "^2.0.0",
"@bufbuild/protoc-gen-es": "^2.1.0",
"@types/debug": "^4.1.12",
"@types/node-forge": "^1.3.9",
"@types/tar-stream": "^3.1.3"
Expand Down
87 changes: 51 additions & 36 deletions packages/connect-conformance/src/callback-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,19 @@
// See the License for the specific language governing permissions and
// limitations under the License.

import { createCallbackClient, ConnectError, Code } from "@connectrpc/connect";
import type { CallbackClient, Transport } from "@connectrpc/connect";
import { ClientResponseResultSchema } from "./gen/connectrpc/conformance/v1/client_compat_pb.js";
import type {
ClientCompatRequest,
ClientResponseResult,
import { create } from "@bufbuild/protobuf";
import {
createCallbackClient,
ConnectError,
Code,
type CallOptions,
type CallbackClient,
type Transport,
} from "@connectrpc/connect";
import {
ClientResponseResultSchema,
type ClientCompatRequest,
type ClientResponseResult,
} from "./gen/connectrpc/conformance/v1/client_compat_pb.js";
import {
UnaryRequestSchema,
Expand All @@ -26,6 +33,8 @@ import {
IdempotentUnaryRequestSchema,
ConformanceService,
ConformancePayloadSchema,
type UnaryResponse,
type IdempotentUnaryResponse,
} from "./gen/connectrpc/conformance/v1/service_pb.js";
import {
convertToProtoError,
Expand All @@ -36,7 +45,6 @@ import {
getSingleRequestMessage,
setClientErrorResult,
} from "./protocol.js";
import { create } from "@bufbuild/protobuf";

type ConformanceClient = CallbackClient<typeof ConformanceService>;

Expand Down Expand Up @@ -70,37 +78,44 @@ async function unary(
await wait(compatRequest.requestDelayMs);
const result = create(ClientResponseResultSchema);
return new Promise<ClientResponseResult>((resolve) => {
const call = idempotent ? client.idempotentUnary : client.unary;
let clientCancelled = false;
const clientCancelFn = call(
getSingleRequestMessage(
compatRequest,
idempotent ? IdempotentUnaryRequestSchema : UnaryRequestSchema,
),
(err, response) => {
// Callback clients swallow client triggered cancellations and never
// call the callback. This will trigger the global error handler and
// fail the process.
if (clientCancelled) {
throw new Error("Aborted requests should not trigger the callback");
}
if (err !== undefined) {
setClientErrorResult(result, err);
} else {
result.payloads.push(response.payload ?? emptyPayload);
}
resolve(result);
const callOptions: CallOptions = {
headers: getRequestHeaders(compatRequest),
onHeader(headers) {
result.responseHeaders = convertToProtoHeaders(headers);
},
{
headers: getRequestHeaders(compatRequest),
onHeader(headers) {
result.responseHeaders = convertToProtoHeaders(headers);
},
onTrailer(trailers) {
result.responseTrailers = convertToProtoHeaders(trailers);
},
onTrailer(trailers) {
result.responseTrailers = convertToProtoHeaders(trailers);
},
);
};
let clientCancelled = false;
const callback = (
error: ConnectError | undefined,
response: UnaryResponse | IdempotentUnaryResponse,
): void => {
// Callback clients swallow client triggered cancellations and never
// call the callback. This will trigger the global error handler and
// fail the process.
if (clientCancelled) {
throw new Error("Aborted requests should not trigger the callback");
}
if (error !== undefined) {
setClientErrorResult(result, error);
} else {
result.payloads.push(response.payload ?? emptyPayload);
}
resolve(result);
};
const clientCancelFn = idempotent
? client.idempotentUnary(
getSingleRequestMessage(compatRequest, IdempotentUnaryRequestSchema),
callback,
callOptions,
)
: client.unary(
getSingleRequestMessage(compatRequest, UnaryRequestSchema),
callback,
callOptions,
);
const { afterCloseSendMs } = getCancelTiming(compatRequest);
if (afterCloseSendMs >= 0) {
setTimeout(() => {
Expand Down

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.

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.

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

Loading

0 comments on commit fe5e10d

Please sign in to comment.