Description
Describe the request
As a consumer of the CLI, I need a way to request terminating the monitor connection; by the time the client receives the response to the request, the resource (port) must be available.
Describe the current behavior
Initially from arduino/arduino-ide#1783 (comment):
IDE2 creates a gRPC bidirectional stream via the
Monitor
method.BeforeIDE2 does an upload, all related monitor connections are closed. IDE2 closes the monitor connection by ending the bidirectional stream and waiting for the OK signal:
I see a race condition; if I put a breakpoint into the code after closing the bidirectional stream (and let the OS clean up the resources), I do not have the
access is denied
error.
CLI should provide a way to terminate the monitor connection gracefully. Calling this API and receiving an OK ack means the port is free.
This is what is happening:
- client (IDE2) ends the stream
- server (CLI) receives the end of the stream, kills the monitor process
- the stream is already closed on the client, it does not wait for the server, the server is still killing the processes (maybe),
- the client starts an upload
- 💥
This is what should happen:
- client (IDE2) send a
STOP
request via the open bidirectional stream,- server receives the
STOP
request (the server is allowed to ignore any other requests received after theSTOP
) and closes the monitor,- server sends a
STOP ACK
equivalent,- client ends the connection,
- server receives the end of stream (noop, the monitor process is already killed)
This is just one of the possible solutions, but the main idea is that IDE2 or any other CLI client might need this way of terminating the monitor.
Arduino CLI version
0.34.0-rc.1
Operating system
macOS
Operating system version
13.5
Additional context
No response
Issue checklist
- I searched for previous requests in the issue tracker
- I verified the feature was still missing when using the nightly build
- My request contains all necessary details