Unable to remove directories recursively

I’m trying to remove directory from a documents folder, the directory was even created by the application using capacitor filesystem plugin,
when I uninstall the app and install again, I need to delete those previous files, but I’m unable to do this, even after hours of trying.
My code fails silently, doesn’t throw any error / exception. Here’s how I’m trying

try {
      await Filesystem.rmdir({
        path: 'lgps_courses',
        directory: Directory.Documents,
        recursive: true,
    } catch (error) {
      alert('Error deleting parent folder: ' + error)