In a large saucepan, melt 1 Tbsp. of the butter over medium-high heat. Add the onions and cook, stirring, until soft, about 3 minutes. Add the mushrooms, thyme, salt, and pepper and the second 1 Tbsp. of butter. Cook, stirring regularly, until the mushrooms start to brown, about 5 minutes. Add the last 1 Tbsp. of butter and stir to melt. Add the flour and cook, stirring constantly for about 30 seconds to a minute. Add the stock and stir while returning the mixture to a boil. Reduce the heat to medium-low and simmer uncovered, stirring occasionally, for 10 minutes.