Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide a gRPC (messaging) way of terminating the monitor connection #2271

Closed
3 tasks done
kittaakos opened this issue Aug 21, 2023 · 0 comments · Fixed by #2276
Closed
3 tasks done

Provide a gRPC (messaging) way of terminating the monitor connection #2271

kittaakos opened this issue Aug 21, 2023 · 0 comments · Fixed by #2276
Assignees
Labels
topic: code Related to content of the project itself topic: gRPC Related to the gRPC interface type: enhancement Proposed improvement

Comments

@kittaakos
Copy link
Contributor

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:

https://github.com/arduino/arduino-ide/blob/69ae38effaf950ae6fba83617b08b1cc0bc0a40d/arduino-ide-extension/src/node/monitor-service.ts#L435

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 the STOP) 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
@kittaakos kittaakos added type: enhancement Proposed improvement topic: code Related to content of the project itself topic: gRPC Related to the gRPC interface labels Aug 21, 2023
@cmaglie cmaglie self-assigned this Aug 21, 2023
@umbynos umbynos added this to the Arduino CLI v1.0.0 milestone Nov 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: code Related to content of the project itself topic: gRPC Related to the gRPC interface type: enhancement Proposed improvement
Projects
None yet
3 participants