Switch crashes while in playing games docked

So I bought a used switch and it’s the launch version, and it crashes whenever I try to play it while it’s docked (except for one game it never crashed Ace Attorney).
I tried another dock and nothing changed, also I tried to change the resolution to 720p but still nothing I tried a lot of different solutions but as you can imagine none of them worked, eventually I ended up finding someone on reddit saying the same thing happened to them and they sent it to Nintendo to fix but I haven’t rly thought about doing that because it’s modded so I basically gave up, and now a year later I’m trying again and hopefully I find an answer here.

Does the picture on tv screen dissapear/go black?
Or does the Switch stop working?

I get a “software was closed due to an error” message and it takes me out of the game other than that the switch works fine

I’m maybe wrong, but from my point of view more a software/firmware problem than a hdmi/docked mode issue.

Did you check that the issue doesn’t appear in handheld?

I did and the issue never happened while playing handheld
Sorry for not including that

What kind of mods are on the Switch?