routeros 6.42.5 and 6.42.6 script /file not working

routeros 6.42.5 and 6.42.6 script /file not working as expected.
the device is RB450Gx4

This code:
:local ddnshost "google.com"
:log info "Hostname = $ddnshost"
:local ddnsip [:resolve $ddnshost]
:log info "IP = $ddnsip"
/tool fetch mode=https address=[:resolve ifconfig.co] port=443 host="ifconfig.co"
src-path="/ip" dst-path="/currentip.txt"
:log info "got here"
:local currentdnsip [/file get "currentip.txt" contents]
:log info "currentip.txt = $currentdnsip"

Upon the first running the output in the LOG ends with "got here".
Yet, the file was created and the contents are correct.

If I remove that file and rerun the script the results are the SAME.

If I do NOT remove the file and then rerun the script the output does include the info entry with "currentip.txt = ...." with the correct result.

I have run this a zillion times and the two alternatives always produce the same inconsistent results.
What is wrong here?

Thanks for any help!
oldunixguy

After the fetch, but before reading the file, put a short delay, like 2 seconds:

:delay 2s;

Unfortunately, this is how it works - the file that has just been downloaded/created locally - is not visible immediately, though the fetch command already finished its job. This is MikroTik’s internal issue (maybe some disk buffering) - known issue and known solution.

Thanks!

Wouldn’t it be wise to add this “workaround” to the manuals, guides, howots, etc. spread all around the internet? I didn’t see this workaround and thus fell into the bug.

How long has this been a problem?

Thanks for the advice!
oldunixguy