Skip to content

cc.arduino.cli.commands.v1.ArduinoCoreService.Init hangs if Monitor is running #2719

Closed
@per1234

Description

@per1234

Describe the problem

A client might make additional cc.arduino.cli.commands.v1.ArduinoCoreService.Init requests.

For example, Arduino IDE periodically (and on demand) performs the following sequence:

  1. Update package and/or library index
  2. Initialize gRPC client instance

Arduino IDE also makes an Init request after installing/updating a platform or library.

🐛 If there is a running cc.arduino.cli.commands.v1.ArduinoCoreService.Monitor process, the Init request hangs.

To reproduce

Equipment

  • Any board or other device that will produce a serial port on your computer.

Demo

  1. Open a terminal.
  2. Start the Arduino CLI gRPC daemon:
    $ arduino-cli version
    
    arduino-cli  Version: git-snapshot Commit: 863c1ec36 Date: 2024-10-06T06:54:36Z
    
    $ arduino-cli daemon
    
    Daemon is now listening on 127.0.0.1:50051
    {"IP":"127.0.0.1","Port":"50051"}
    
  3. Open another terminal.
  4. Run the following grpcurl command in the new terminal to create a gRPC client instance:
    $ grpcurl \
      -plaintext \
      -import-path ./rpc \
      -proto cc/arduino/cli/commands/v1/commands.proto \
      127.0.0.1:50051 \
      cc.arduino.cli.commands.v1.ArduinoCoreService.Create
    
    {
      "instance": {
        "id": 1
      }
    }
    
  5. Run the following command to initialize the instance:
    $ grpcurl \
      -plaintext \
      -import-path ./rpc \
      -proto cc/arduino/cli/commands/v1/commands.proto \
      -d '{"instance": {"id": 1}}' \
      127.0.0.1:50051 \
      cc.arduino.cli.commands.v1.ArduinoCoreService.Init
    
  6. Run the following command to start a Monitor request:
    $ grpcurl \
      -plaintext \
      -import-path ./rpc \
      -proto cc/arduino/cli/commands/v1/commands.proto \
      -d @ \
      127.0.0.1:50051 \
      cc.arduino.cli.commands.v1.ArduinoCoreService.Monitor
    
  7. Send the request data to open the available serial port:
    ❗ Adjust the value of open_request.port.address as is appropriate for the port on your computer.
    {
      "open_request": {
        "instance": { "id": 1 },
        "port": { "address": "COM42", "protocol": "serial" }
      }
    }
  8. Open another terminal.
  9. Run the following command in the new terminal to reinitialize the gRPC client instance:
    $ grpcurl \
      -plaintext \
      -import-path ./rpc \
      -proto cc/arduino/cli/commands/v1/commands.proto \
      -d '{"instance": {"id": 1}}' \
      127.0.0.1:50051 \
      cc.arduino.cli.commands.v1.ArduinoCoreService.Init
    

🐛 The reinitialization hangs.

Expected behavior

cc.arduino.cli.commands.v1.ArduinoCoreService.Init does not hang under any conditions.

Arduino CLI version

863c1ec

Operating system

  • Linux
  • macOS
  • Windows

Operating system version

  • Ubuntu 24.04
  • macOS Sonoma
  • Windows 11

Additional context

I bisected the regression to bb815cf / #2565 (the fault does not occur when using the build from the previous commit 917dcc5).


Originally reported at #2347 (comment) (note the original issue report #2347 was from long before the time of the regression, so is different from the Monitor-specific issue tracked here even if the symptoms are somewhat similar).

Additional reports

Issue checklist

  • I searched for previous reports in the issue tracker
  • I verified the problem still occurs when using the nightly build
  • My report contains all necessary details

Metadata

Metadata

Assignees

Labels

conclusion: resolvedIssue was resolvedtopic: codeRelated to content of the project itselftopic: gRPCRelated to the gRPC interfacetype: imperfectionPerceived defect in any part of project

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions