I got a bootloop after installing a magisk module 'nabarswap' and had to wipe the device with Android flashtool
In addition to what
@foobar66 said about safe mode, you can also remove modules by this method, but it's easier just to disable them in safe mode like foobar66 said:
1. Turn off device
2. adb wait-for-device shell magisk --remove-modules in command prompt
3. Connect your phone to computer and turn it on.
4. Phone tries to boot and the command should be accepted
5. Wait until the command worked and the phone boots up without issues
Also, there is a Magisk Mod that will automatically disable mods if you are in a bootloop. I have it installed but haven't tested it since I haven't been in a bootloop. The developer said it supports Android 12. I've seen at least 1 person who said it works.
Protect your system from bootloop caused by Magisk modules. - GitHub - Magisk-Modules-Alt-Repo/HuskyDG_BootloopSaver: Protect your system from bootloop caused by Magisk modules.
github.com