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

nest/src/microservices/client/client-tcp.ts#L43. There is a bug or problem here. #491

Closed
whtiehack opened this issue Mar 9, 2018 · 3 comments

Comments

@whtiehack
Copy link

protected async sendSingleMessage(msg, callback: (...args) => any) {
const sendMessage = socket => {
socket.sendMessage(msg);
socket.on(MESSAGE_EVENT, buffer =>
this.handleResponse(socket, callback, buffer),
);
};
if (this.isConnected) {
sendMessage(this.socket);
return Promise.resolve();
}

I'm submitting a...


[ ] Regression 
[X] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

socket.on(MESSAGE_EVENT, buffer =>
When I provide a wrong pattern.
For example, { cmd: 'sum' } is written as { cmd: 'sum1' }.
Each time you send a message, it binds once. This callback function is called N+1 times.
So is this a performance issue and a memory leak?
Or is there any way to catch the pattern error?

Expected behavior

Can be properly disposed.

Minimal reproduction of the problem with instructions

  @MessagePattern({ cmd: 'sum' })
  sum(data: number[]): number {
    return (data || []).reduce((a, b) => a + b);
  }

and


  @Get('/micro')
  async testMicroService(){
    return await this.microClientService.testMicroClient.send<number>({cmd:'sum1'},[1,2,3,4,5])

  }

What is the motivation / use case for changing the behavior?

Environment


Nest version: �latest

 
For Tooling issues:
- Node version: 8.9.4  
- Platform:  mac

Others:

@whtiehack
Copy link
Author

I think this is a bug. I tried to fix and submit a PR.

@kamilmysliwiec
Copy link
Member

Thanks for reporting, I'm on it. 🙂

@lock
Copy link

lock bot commented Sep 25, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Sep 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants