If you load a broken file (a file with syntax errors) to the module named as init.lua and run it (or restart the module) the result will be be trapped into endless boot loop.
The module will prompt you with a message and after a while will boot again.
A message will look line this:
> PANIC: unprotected error in call to Lua API (init.lua:57: unexpected symbol near 'true')
Maybe I'm wrong but in this case the only solution I found to escape this bootloop trap is to reflash the module with the firmware! (I need you opinion on this)
However by tricking the start up process you can avoid an error like this.
This is the best solution for this problem for the moment:
Use the following code as init.lua and pass to NextFile variable your actual code. By using this trick you will get 5 seconds delay no matter the NextFile brings.
This is enough time to delete or rename the tricky file and start over with a new try.
l = file.list();
for k,v in pairs(l) do
-- print("name:"..k..", size:"..v)
if k == NextFile then
print("Wait 5 seconds please")
tmr.alarm(0, 5000, 0, function() dofile(NextFile) end)
print("Started file ".. NextFile)
-- do nothing
print("End of startup")
PANIC: unprotected error in call to Lua API (attempt to index a nil value)