Closed alronz closed 6 years ago
I am using the recognition services and I get duplicates events when I call any function of the recognition service (train, getTags, etc ..) more than once. For example: the below code:
matrix.service('recognition').getTags() .then((tags) => { console.log('tags results'); })
Will produce "tags results" twice on the second time if I call the above function twice.
I guess the problem is from the below line: https://github.com/matrix-io/matrix-os/blob/dev/apps/lib/service.js#L192
It seems this problem is similar to the below issue: https://github.com/nodejs/node-v0.x-archive/issues/2475
https://github.com/nodejs/node-v0.x-archive/issues/2475
I have tried changing the above to process.once and it worked.
For now in my code I just use the below after calling any function from the recognition service: process.removeAllListeners('message');
process.removeAllListeners('message');
I hope you fix it soon if you think it makes sense.
Thanks !
Hi @alronz thanks for the help. I've just merged to dev, fixing this. Yes, the once makes more sense and stop this duplicates. Thanks :)
once
I am using the recognition services and I get duplicates events when I call any function of the recognition service (train, getTags, etc ..) more than once. For example: the below code:
Will produce "tags results" twice on the second time if I call the above function twice.
I guess the problem is from the below line: https://github.com/matrix-io/matrix-os/blob/dev/apps/lib/service.js#L192
It seems this problem is similar to the below issue:
https://github.com/nodejs/node-v0.x-archive/issues/2475
I have tried changing the above to process.once and it worked.
For now in my code I just use the below after calling any function from the recognition service:
process.removeAllListeners('message');
I hope you fix it soon if you think it makes sense.
Thanks !