Debugging a strange error where messages only work every other time