Melt butter on a dutch oven or any large pot. Add the chopped onions and cook on medium heat until fully caramelized. This process will take roughly 40-45 minutes. Stir occasionally in the beginning and often toward the end. About 38-40 minutes into the process, add in the sugar and garlic and continue stirring. When the onions are medium brown (not burned) and fully caramelized, add in the flour to slightly thicken the broth, stir. Add the wine and using a wooden spoon, scrape up every bit of onion that may be attached to the bottom of the pan. Add in the beef stock, fresh thyme and half cover the pot, allowing it to simmer for 15 minutes.