Oh, that's a pretty simple fix in that case, I just need to add Krastorio as an optional dependency, forcing it to load first, so my mod never sees this recipe before it's deleted.
I'm not really sure if I actually can add any sort of logic check if this situation occurs. My code already takes place in data-final-fixes, which is the last point in the game I can load. Anything else that uses data-final-fixes then has the potential to load either before or after my mod, depending on dependencies (which is semi-random).
My mod just reverses every item that has a related recipe, and that's it. If another mod changes the recipe list after mine, I literally can't go back and check, because my mod has completed all its tasks. All I can do is force the load order in that case.
I've had many cases where having a completely unrelated mod changed the load order and prevented a crash like this, and others who didn't have that mod experienced the issue. It's the most annoying part about maintaining a mod like this.