I’m afraid I have to give up. You are probably doing something wrong and possibly hit a bug or at least inelegant handling of a bug in your code. Seems this needs a reproducing example or at least a decent snippet of the code that is likely responsible with a decent description on how this code is being used.
Good luck.