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

typing issue with custom grpc callOptions on single operation #187

Open
0xb4lamx opened this issue Jan 17, 2025 · 1 comment · May be fixed by #189
Open

typing issue with custom grpc callOptions on single operation #187

0xb4lamx opened this issue Jan 17, 2025 · 1 comment · May be fixed by #189

Comments

@0xb4lamx
Copy link

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/@[email protected]/node_modules/@grpc/grpc-js/src/client.ts:229:15)
        at Proxy.makeUnaryRequest (/xxxxxxx/api/node_modules/.pnpm/@[email protected]/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
@tstirrat15
Copy link
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.

@tstirrat15 tstirrat15 linked a pull request Jan 21, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants