In a large pot melt the butter and add in the onions, garlic and thyme sprigs and sweat off over a medium heat for about 10 minutes or until they have partially softened and turned brown and caramelised.
Add in the brown sugar at this stage and allow it to dissolve completely with the onions.
Next add in the plain flour and use it to both coat the onions and dry up any liquids in the pan.
Pour in the wine which will immediately begin to thicken as it reacts with the flour.
Gradually add the beef/chicken stock to the onion mixture.
Season with salt and pepper.
Stir slowly and then simmer for about 45 minutes or until the onions are soft and the soup has reduced.
Roll out the pastry on a lightly floured surface and using the top of your serving bowl as a template, allow an extra inch around and cut the pastry.
Lightly brush the bowl edge with eggwash and place the pastry disc on the surface.
Brush the pastry with egg wash and sprinkle some cheese on top of each pastry disc.
Place in a preheated oven at 180C/350F/Gas Mark 4 for 12 minutes.