Melt the butter in a large heavy-based pan, and cook the onions, garlic, thyme and rosemary in it until the onions are translucent, about 5–10 minutes.
Add the chestnuts and cook lightly for a further 5 minutes. Stir in both types of mushroom and cook for a further 2 minutes. Pour in the Madeira and reduce by two-thirds. Add the stock or water, bring to the boil and simmer for 15 minute