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

Bug: Wrong response type detection for newest grpc-js package #374

Open
ScripterSugar opened this issue Mar 18, 2024 · 3 comments
Open

Bug: Wrong response type detection for newest grpc-js package #374

ScripterSugar opened this issue Mar 18, 2024 · 3 comments

Comments

@ScripterSugar
Copy link
Contributor

ScripterSugar commented Mar 18, 2024

Describe the bug
As of now, mali inspects the type of call constructor of context request/response object in grpc server implementation, as we can see below:

function getCallTypeFromCall (call) {
  const name = Object.getPrototypeOf(call).constructor.name

  if (name.indexOf('ServerUnaryCall') === 0) {
    return CallType.UNARY
  } else if (name.indexOf('ServerWritableStream') === 0) {
    return CallType.RESPONSE_STREAM
  } else if (name.indexOf('ServerReadableStream') === 0) {
    return CallType.REQUEST_STREAM
  } else if (name.indexOf('ServerDuplexStream') === 0) {
    return CallType.DUPLEX
  }
}

However, an update to the @grpc/grpc-js package 2 months ago modified the unary call handler to use ServerWritableStreamImpl instead of ServerUnaryCallImpl. Consequently, Mali now mistakenly identifies all unary calls as stream calls.

To Reproduce
Steps to reproduce the behavior:
Install newest grpcjs package as peer dependency, and make unary call to mali instance.

Expected behavior
It should differentiate the unary and stream calls separately as intended.

Environment

  • Version: 0.47.1
  • Node.js version: 20
  • OS: macOS 14.0(23A344)
@ScripterSugar
Copy link
Contributor Author

ScripterSugar commented Mar 18, 2024

to resolve the issue, we can modify getCallTypeFromCall to reference call.call.handler.type. it is defined in type 'bidi' | 'clientStream' | 'serverStream' | 'unary'.

@fabiosangregorio
Copy link

PR got merged 🎉 Let's hope for a new release soon 🤞🏻

@koliaVasyliv
Copy link

hey, @anonrig just reminding about this issue, as it's already merged, could you please release this fix, it would be really helpful as it's blocking usage of the latest grpc-js version for half a year.

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

No branches or pull requests

3 participants