Preheat the oven to 200°C (400°F) and line a baking sheet with parchment paper.
Heat olive oil or butter in a skillet over medium heat. Add onion (if using) and cook for 3–4 minutes until soft.
Stir in garlic, mushrooms, salt, pepper, and thyme. Cook for 8–10 minutes, stirring occasionally, until most of the moisture is gone.
Stir in chopped parsley, then remove from heat and let the mixture cool completely.
Roll out the thawed puff pastry on a lightly floured surface into a rectangle (if needed).
Spread the cooled mushroom mixture evenly across the pastry, leaving a 1-inch border on one long edge.
Sprinkle grated parmesan over the filling.
Starting from the long edge opposite the border, roll the pastry into a tight log.
Pinch the seam to seal, place seam-side down, and chill the roll for 10 minutes.
Slice into ½-inch (1.25 cm) rounds and arrange on the prepared baking sheet, cut-side up.
Brush the tops with beaten egg.
Bake for 18–22 minutes or until golden, puffed, and crisp on the edges.
Let cool slightly before serving. Garnish with extra chopped parsley if you’d like.