Stephen C's answer is probably the best answer to the problem, even if it is not an answer to the question. Although my string size was more than 4k already, I was still likely to eventually have the problem again during the lifetime of the product
aioobe's answer is the best answer to the actual question, perhaps not the actual problem.