In https://github.com/kennyledet/Algorithm-Implementations/blob/master/Dijkstra%27s_Shortest_Path/Lua/Yonaba/dijkstra.lua lines 84 and 85 seems to be reversed.
if u == target then return backtrace(u) end
if u.distance == math.huge then break end
As it is, you can detect a target arrival through a non-existing link.