@NickB said that the function node sometimes does not pass on the messages, which would have to be a different problem I think.
An alternative to your solution of using the queue, which might be simpler I think, would be to use node-red-contrib-semaphore.