XIAO 2040 Takes forever to compile and incurs uploading errors

Which IDE and SDK are you using?

If it is Arduino, there are two boards packages: one works, the other not.

See XIAO RP2040, RP2040 SDK and APIs - #10 by reivilo to pick the right one.