There is also the poor man's gdb: put dbg!(); everywhere before and after all suspicious lines. (or even every two lines)
dbg!();