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

Latest grpc-js breaks mali ctx.res.pipe #376

Open
kirrg001 opened this issue Apr 4, 2024 · 4 comments
Open

Latest grpc-js breaks mali ctx.res.pipe #376

kirrg001 opened this issue Apr 4, 2024 · 4 comments

Comments

@kirrg001
Copy link

kirrg001 commented Apr 4, 2024

Hey!

  TypeError: ctx.res.pipe is not a function
      at execStream (grpc-mali-rep/node_modules/mali/lib/run.js:53:13)
      at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Demo

test.proto

syntax = "proto3";

package myservice.node.grpc.test;

message TestRequest {
  string parameter = 1;
}

message TestReply {
  string message = 1;
}

service TestService {
  rpc MakeUnaryCall (TestRequest) returns (TestReply) {}
}

server.js

const port = process.env.APP_PORT || 28428
const Mali = require('mali');
const express = require('express');
const path = require('path');
const expressApp = express();

async function MakeUnaryCall(ctx) {
  ctx.res = { message: 'Hey' };
}

const maliApp = new Mali(path.join(__dirname, 'test.proto'));

maliApp.use({
  MakeUnaryCall
});

maliApp.start('127.0.0.1:50051');

expressApp.get('/', (req, res) => {
  res.send('OK');
});

expressApp.listen(port, () => {
    console.log(`Listening on port: ${port}`);
});

client.js

const port = process.env.APP_PORT || 30484
const bodyParser = require('body-parser');
const express = require('express');
const grpc = require('@grpc/grpc-js');
const path = require('path');
const app = express();
const PROTO_PATH = path.join(__dirname, 'test.proto');

let client;
let makeUnaryCall;

function runClient() {
  const protoLoader = require('@grpc/proto-loader');
  const packageDefinition = protoLoader.loadSync(PROTO_PATH, {
    keepCase: true,
    longs: String,
    enums: String,
    defaults: true,
    oneofs: true
  });

  const testProto = grpc.loadPackageDefinition(packageDefinition).myservice.node.grpc.test;
  client = new testProto.TestService('localhost:50051', grpc.credentials.createInsecure());
}

runClient();

app.use(bodyParser.json());

app.get('/', (req, res) => {
  res.send('OK');
});

app.post('/unary-call', (req, res) => {
    client.makeUnaryCall({}, (err, reply) => {
	if (err) {
	    return res.send(err);
	}
	const message = typeof reply.getMessage === 'function' ? reply.getMessage() : reply.message;
	return res.send({ reply: message });
    });
});

app.listen(port, () => {
  console.log(`Listening on port: ${port}`);
});

package.json

{
  "name": "grpc-mali-rep",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "@grpc/grpc-js": "^1.10.6",
    "body-parser": "^1.20.2",
    "express": "^4.19.2",
    "mali": "^0.47.1"
  }
}

CURL -X POST http://localhost:30484/unary-call

Thanks!

kirrg001 added a commit to instana/nodejs that referenced this issue Apr 4, 2024
kirrg001 added a commit to instana/nodejs that referenced this issue Apr 5, 2024
kirrg001 added a commit to instana/nodejs that referenced this issue Apr 5, 2024
@n0v1
Copy link
Contributor

n0v1 commented Jul 5, 2024

Note: This was fixed by #375 but a new version containing this fix was not released yet.

@yoitsro
Copy link

yoitsro commented Oct 9, 2024

Hey @n0v1. Is there any likelihood that the new version will be published soon?

@n0v1
Copy link
Contributor

n0v1 commented Oct 10, 2024

@yoitsro, I don't know as I'm not a maintainer of this repo. @bojand and @anonrig last replied in May (see #378).

@yoitsro
Copy link

yoitsro commented Oct 10, 2024

Seems like you should be made a co-maintainer ;) I'd also be happy to be made co-maintainer @bojand @anonrig 🙏

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