An example of this bug occurring is the “Make Lights” slot. Ensure all vehicles are set to use an upgrade light (say Directional Lights), but do not upgrade the Make Lights slot. Once the stockpile fills up, upgrade the slot to produce Directional Lights. Notice that the stockpile is full of regular lights that are not removed to make room for the new Directional Lights.
That is actually by design, those items do exist and you would have to use them up. You can pause the operation of any slot (the pause button is next to the slot progress bar) to manage a change of this kind.
I just tried this out with a different slot (Fit Lights), and your answer seems inconsistent with what happened. I already had Directional Lights researched and upgraded on the slot, then proceeded to research and upgrade to Xenon Lights (resulting in a need for Directional Xenon Lights).
The first vehicle that was in the slot when I paused it to upgrade and test got the old Directional Lights installed, freeing up some stockpile space. The next vehicle required Directional Xenon Headlights and waited for them to be imported. There remained 11 Directional Lights in the stockpile until a couple vehicles later when they all vanished, and it requested 12 Directional Xenon Lights and one regular Light (this regular Light seems to be imported, never used by a vehicle, gets removed from the Stockpile requests, then re-appears over and over).
Regardless of the bug (or design), it seems strange to keep a stockpile of items that will never be used again (since all models have been changed to not use that item any more). I would expect the items to be refunded (similar to how they are when you start producing your own parts) instead of creating a stockpile bottleneck. Even if they aren’t refunded, just getting rid of them without having to change a model to use them and switching the model back quickly to avoid stockpiling more would be nice.
There are two different cases:
Stockpile in Make slots. Items have to be needed somewhere else (Fit slot or Supply Stockpile) to leave the stockpile. If you upgrade this slot, you have to dispose of the old resources yourself.
Stockpile in Fit slots. Items seem to disappear after a small amount of time if no car needs them.
Furthermore, there is a bug where the Fit Light slot continues to stock standard lights (and discard them). I fix it in-game by setting the import priority to local only for theses.