-
-
Notifications
You must be signed in to change notification settings - Fork 17
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
FW Uploader might provide a broken JSON #166
Comments
Hi @kittaakos, when this happens, could you please attach the content of |
I got the same error. I do not see any problem with the JSON: fwuploader-gh-166.zip. How is the |
The json inside looks ok to me.. When you run |
I got an exception again with IDE2 2.1.0 on Windows (this time). The JSON file looks correct in the temp folder.
|
The same has happened when starting IDE2 from sources on Windows:
|
We had a similar problem with the Arduino CLI running sub-processes in the past, the issue was that the child process may exit and return an exit code before we actually consume all the output. It wasn't really clear from the documentation, but we had to consume all the stdout stream until EOF before exiting the run loop. May it be the same here? |
@cmaglie, could you please reference the corresponding commit/PR in the CLI repository? Thanks! |
I've been searching for the PR just after writing the comment but it seems I'm not able to find it :-/. Anyway, this is an example of what I was talking about (of course it's in golang, I don't know if it applies to JS/TS): func main() {
// Create a pipe
in, out, _ := os.Pipe()
// Spawn a thread that copies the out-side of the pipe to os.Stdout
go func() {
io.Copy(os.Stdout, in)
}()
// Exec command
cmd := exec.Command("/usr/bin/cat", "test")
cmd.Stdout = out // Send command output to the in-side of the pipe
_ = cmd.Run()
out.Close()
fmt.Println("PROCESS EXITED") // <-- The copy thread may still not be completed here!!
time.Sleep(time.Second)
} I've created a very big file called
instead of the expected
so the obvious patch is to wait for completion of the thread: func main() {
// Create a pipe
in, out, _ := os.Pipe()
// Spawn a thread that copies the out-side of the pipe to os.Stdout
doneCopying := make(chan bool)
go func() {
io.Copy(os.Stdout, in)
close(doneCopying) // PATCH: Signal copy completion
}()
// Exec command
cmd := exec.Command("/usr/bin/cat", "test")
cmd.Stdout = out // Send command output to the in-side of the pipe
_ = cmd.Run()
out.Close()
<-doneCopying // PATCH: wait for copy thread to complete
fmt.Println("PROCESS EXITED") // everything's good! :-)
time.Sleep(time.Second)
} Hope this may help! |
Maybe related:
|
I see a new kind of error. It's started yesterday
|
Describe the problem
From time to time, when I start IDE2, the firmware uploader does not provide a valid JSON when executing
./arduino-fwuploader" firmware list --format json
.IDE2 error is:
To reproduce
I do not know the exact steps to reproduce, but I see the same error almost weekly in the logs.
Expected behavior
The
firmware list --format json
command provides a valid JSON.Arduino Firmware Uploader version
arduino-fwuploader Version: 2.2.2 Commit: 8944d4a Date: 2022-10-17T14:51:09Z
Operating system
macOS
Operating system version
12.6.3
Additional context
No response
Issue checklist
The text was updated successfully, but these errors were encountered: