Skip to content

typing issue with custom grpc callOptions on single operation #187

Open

Description

@0xb4lamx

hey! I've faced few typing issues when trying to customize some grpc callOptions per operation.

details

considering that client is created via v1.NewClient() . a request with custom callOptions

    const response = await this.client.checkBulkPermissions(
      checkBulkPermissionsRequest,
      undefined,
      { deadline: Date.now() + config.SPICEDB_GRPC_TIMEOUT_MS }
    );

will build fine, but on runtime, gRPC calls will fail with:

 Trace: Error: Incorrect arguments passed
        at Proxy.checkOptionalUnaryResponseArguments (/xxxxxxx/api/node_modules/.pnpm/@grpc+grpc-js@1.12.5/node_modules/@grpc/grpc-js/src/client.ts:229:15)
        at Proxy.makeUnaryRequest (/xxxxxxx/api/node_modules/.pnpm/@grpc+grpc-js@1.12.5/node_modules/@grpc/grpc-js/src/client.ts:277:12)
        at Proxy.checkBulkPermissions 

==
but doing it this way

    const response = await this.client.checkBulkPermissions(
      checkBulkPermissionsRequest,
      { deadline: Date.now() + config.SPICEDB_GRPC_TIMEOUT_MS }
    );

works fine, but will TS type fail 🤔

env

"@authzed/authzed-node": "^1.1.1",
"typescript": "5.4.4",
node v22

Activity

  1. tstirrat15 commented on Jan 21, 2025

    @tstirrat15
    Contributor

    I think I see the issue.

    https://github.com/authzed/authzed-node/blob/main/src/authzedapi/authzed/api/v1/permission_service.grpc-client.ts#L82-L84

    There's multiple overloads of the checkBulkPermissions function. We're then patching over the client using promisify, and I think it's effectively selecting the wrong overload, which is why typescript and the runtime appear to disagree.

    We're doing some mucking around with the types in https://github.com/authzed/authzed-node/blob/main/src/types.ts#L80-L106, which is probably the source of the issue. I've at least got a reproduction locally.

    I'll keep you posted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions