Possibly to do with how you determine the shape to extrude. My method uses a ribbon rather than extrudeShape (which by the way uses createRibbon to build the extrusion)
From my point of view your code is somewhat too complex for me to spend time checking especially as I doubt it is a Babylonjs error. You could do a couple of checks by drawing your shape to extrude with CreateLines and the same for your path.
You could use ExtrudeShape with my method however to set the shape to extrude you would need to rotate the facet so that it lies on the xy plane and then read its rotated vertex positions