It can take years. I've bought new guns that had been discontinued for years.
It probably sits for awhile at the factory and then definitely at the distributor until it's ordered by a retailer. I think that sometimes they get pushed to a back shelf and sit for longer than intended. Then, it can sit at the retailer quite a long time if the retailer guesses incorrectly at demand level or at the saleability of a particular firearm.
They might even get sent back to a distributor if the retailer can't move them.
The SIG P250 is probably an example of a gun that retailers thought would fly off the shelves given their price and unique features. Instead, they haven't proved to be very good sellers in many areas.