For me, it looks like lastError() is not active meaning when you check lastError().isActive(), it should return false because your query is successful. I would read it like that.
Thank you. You are write I am still a bit of a noob, I should be using clearer code when setting up debugging along with further research of the method.