When I run the script, I get the exact same error message.
This bricked XIAO cannot be connected to JLink via the pads on the back, so there is currently no way to recover it.
EDIT:
After repeatedly resetting it, reconnecting the USB, and running the script over and over, it suddenly managed to perform a full erase. However, when I run the script again, it sometimes throws an error, sometimes performs a full erase again—it’s extremely unstable.
EDIT:
Running the script fixes the issue, but it quickly becomes impossible to upload files while using it.