I don't know if its related, but every time you run it, it "leaks" a couple of PIPEs.
I tried the following:
% sdk=~/Library/ApplicationSupport/Garmin/ConnectIQ/Sdks/connectiq-sdk-mac-4.1.7-2022-11-21-562b8a195 % $sdk/bin/connectiq % while $sdk/bin/monkeydo bin/test.prg fenix5 -t > /dev/null do date lsof -p $(pgrep -f 'connectiq-sdk.*[/\\]simulator$') | grep PIPE | wc -l done
It shows the time, and number of open pipes after each iteration. Typically, it does about 20 runs before hanging, but I've seen as few as three, and as many as fifty. Once it hangs, killing the script, and trying to run it again, or run something else always hangs. I have to quit from the simulator (or kill it) to get it going again. Here's what I just got from the script.
Tue Jan 17 16:08:28 PST 2023 4 Tue Jan 17 16:08:31 PST 2023 6 Tue Jan 17 16:08:34 PST 2023 8 Tue Jan 17 16:08:37 PST 2023 10 Tue Jan 17 16:08:40 PST 2023 12 Tue Jan 17 16:08:42 PST 2023 14 Tue Jan 17 16:08:45 PST 2023 16 Tue Jan 17 16:08:48 PST 2023 18 Tue Jan 17 16:08:51 PST 2023 20 Tue Jan 17 16:08:53 PST 2023 22 Tue Jan 17 16:08:56 PST 2023 24 Tue Jan 17 16:08:59 PST 2023 26 Tue Jan 17 16:09:02 PST 2023 28 Tue Jan 17 16:09:04 PST 2023 30 Tue Jan 17 16:09:07 PST 2023 32 Tue Jan 17 16:09:10 PST 2023 34 Tue Jan 17 16:09:13 PST 2023 36 Tue Jan 17 16:09:18 PST 2023 38
The fact that the number of runs varies so much makes me think the pipe issue is a red herring; otoh it's almost certainly a bug that they're not being closed properly.
I did notice that the release notes for the v1.0.7 "Garmin MonkeyC" extension say "Fix issue with simulator timeout when launching an app with the 4.1.6 SDK", and in fact if I run my script until it hangs, then run something via the vscode extension, the first try will usually tell me that it failed to connect to the debugger, then subsequent tries work - suggesting that the extension has some kind of trick to "unstick" the simulator that the command line tools don't know about (it doesn't seem to kill and restart the simulator).