Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V2: Update dependencies #1239

Merged
merged 2 commits into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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