Factorio translator(EN<->PL)
Factorio mods translator(EN<->PL)
Wiki translator(EN<->PL) - waiting for approval
Wiki contributor(EN, PL) - waiting for approval
Do you want your mod to be translated? Request it there: Click!
This is because when fast replacing, the circuit network is disconnected. Because it's the last connection, the network is destroyed. When the new connection is made, a new circuit network is created and thus it will be empty for 1 tick, making your <0 condition be true.
It's a bug, but unfortunately fixing it would require quite a big refactor of the fast replace logic for circuit networks.
So I would consider it a minor known issue.
This won't happen if the inserter was connected to something else.