Client does not complete send operation until async block of code is reached
We've noticed a performance issue with @grpc-js in our performance logging workflow. It's set up so that a client periodically sends small messages to a server every 500ms. Unfortunately, the server does not receive any of these until the client process reaches an async block of code, at which point all previously queued messages are sent in a massive burst. The messages stay in a sort of queue for however long it takes to reach the next await block, which in our scenario takes up to a minute.
After some debugging, we've found that http2Stream!.write(message, cb) is indeed successfully called immediately after every send request, but that the operation is not performed and the cb is not invoked until the next block of async code.
This is not a question of performance - 500ms is more than enough time to send and receive a small message between local processes.
If I understand correctly, you are saying that you have confirmed that http2Stream!.write is called in the same synchronous context as when you send the message. That is the point where gRPC passes the message along to the built in http2 module. This means that the http2 module must be responsible for this async wait that you are seeing.