I just noticed that we use the same `command` inst...
# 💻|contributing
b
I just noticed that we use the same
command
instance again and again in the ws server instead of doing
command = new CommandClass()
This means that all the subscribers get added to the same instance. Now, when e.g. streaming logs, the subscriber callback gets called for each log event on all subscribers. So e.g. a log from the
api
service gets called on
api
,
postgres
,
vote
et al (assuming the vote example project). This means the logs viewer will print the same log line for each subscribing service. I'm not entirely sure why this worked on 0.12 tbh but it's certainly an issue on 0.13. My first reaction would be to initialise the command per request as opposed to pre-initialising, but not sure how that jives with other invariants. We've been pre-initialising commands in the
commands/commands.ts
file for forever. A quick fix would be to handle this in the callback and only send a message for the services the callback cares about, but that feels pretty hacky and doesn't generalise to other commands. Any thoughts? (cc @alert-helicopter-61082 , since you've done some work on this)
a
I think we should indeed create a new instance per request.
It's basically a non-concern for the CLI runner in normal cases, but making the commands list a list of constructors could be better in general.
b
Yeah that's what I was thinking. Makes sense. If required, we could also have a constructor list for the general case and an initialised version for the CLI that maps over the constructor list. Don't think that it is though.
a
> Don't think that it is though. ?
Ah, that it is required
Ambiguous references 🙂
b
Haha my bad
2 Views