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

Compilation using source override fails if sketch file content longer than maximum gRPC message length #2718

Open
3 tasks done
per1234 opened this issue Oct 4, 2024 · 0 comments
Labels
topic: code Related to content of the project itself topic: gRPC Related to the gRPC interface type: imperfection Perceived defect in any part of project

Comments

@per1234
Copy link
Contributor

per1234 commented Oct 4, 2024

Describe the problem

The cc.arduino.cli.commands.v1.ArduinoCoreService.Compile request message of Arduino CLI's gRPC interface has a sourceOverride field:

This map (source file -> new content) let the builder use the provided content instead of reading the corresponding file on disk. This is useful for IDE that have unsaved changes in memory. The path must be relative to the sketch directory. Only files from the sketch are allowed.

The design of the field is such that the entire content of the sketch file must be sent in a single message.

🐛 The compilation will fail spuriously if the field is used with a sketch file with content larger than the default maximum gRPC message length.

To reproduce

It will probably be most convenient to use Arduino IDE to reproduce the fault:

  1. Click the following link to download the demo sketch:
    BigFileSketch.zip
  2. Extract the downloaded ZIP file.
  3. Open the sketch from the extracted folder in Arduino IDE.
  4. Select File > Preferences... (or Arduino IDE > Settings... for macOS users) from the Arduino IDE menus.
    The "Preferences" dialog will open.
  5. Uncheck the box next to "Auto save" in the "Preferences" dialog.
  6. Click the "OK" button.
    The "Preferences" dialog will close.
  7. Add a blank line to the top of the sketch.
    This is an arbitrary innocuous change in order to put the editor into the "dirty" state, which will cause Arduino IDE to send the contents of the sketch through the sourceOverride field of the cc.arduino.cli.commands.v1.ArduinoCoreService.Compile request message.
  8. Select Sketch > Verify/Compile from the Arduino IDE menus.

🐛 Compilation fails:

grpc: received message larger than max (4226107 vs. 4194304)

Compilation error: grpc: received message larger than max (4226107 vs. 4194304)

Expected behavior

The API is designed in a way that allows the source override feature to be used even with large sketch files.

Arduino CLI version

1.0.4

Operating system

Windows

Operating system version

Windows 11

Additional context

Originally reported at https://forum.arduino.cc/t/compilation-error-grpc-received-message-larger-than-max-4322345-vs-4194304/1304422


A silly contrived sketch was used in the demo for the sake of simplicity. For an example of a real world sketch that also produces the fault, see:

https://forum.arduino.cc/t/compilation-error-grpc-received-message-larger-than-max-4322345-vs-4194304/1304422/5

Workaround

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
@per1234 per1234 added topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project topic: gRPC Related to the gRPC interface labels Oct 4, 2024
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: imperfection Perceived defect in any part of project
Projects
None yet
Development

No branches or pull requests

1 participant