That is a known issue, where the game can run out of handles for generating items. Reverting to an older save and avoiding too much crafting and selling items to NPC can help, but unfortunately there isn't really any way to tell how far back would be safe, since you wouldn't be able to avoid crafting and trading completely and items would still need to be generated.