Fetch often times out in script, never at command line, and not when I enable fetch logging

Yes, the idle-timeout is in seconds.

In my testing, the fetch either works within 1-2 seconds, or it doesn’t work at all. I’ve removed the idle-timeout now, since the default of 10s is more than sufficient.

I’ve also enhanced the script to loop over the fetch command up to 5 times before giving up; here is the relevant part of the script. (n.b. while I think I’ve got this right, I’m still waiting for the error to recur, to make sure that the error is caught and reported; if I find that I have to update the script further, I’ll post back again alter). Nope, the fetch, when it timed out, would still break the script. I’ve further updated the script to put the fetch in its own :do { … fetch … } sub-function, as I saw described at RouterOS Bug - Why Do These Simple Scripts Break? Cause of Mysterious "value:" Prompt?

:do {
:local unused [:do {
:set result [/tool fetch url="http://checkip.dyn.com" output=file dst-path="/dyndns.checkip.html" as-value]
} on-error={ :log warning "Update Dynamic DNS v3 fetch failed, attempt# $loopcount"; } ];
:if ($result->"status" = "finished") do={ :set loopsucceeded 1;} else={:set loopcount ($loopcount + 1)};
} while=($loopsucceeded=0 && $loopcount < 5);

#check that we didn't just repeatedly timeout
:if ($loopsucceeded=0) do={ :error "Update Dynamic DNS v3 failed, fetch timed out five times in a row"}
:if ($loopcount > 1) do={ :put "Update Dynamic DNS v3 fetch retried $loopcount times"}

#Okay, we got here, so the fetch (eventually) worked, get the result
:set result [/file get dyndns.checkip.html contents]

#parse the current IP result