What’s happening to you is a known bug.
I know it’s on Github somewhere…
EDIT: Here was my post encountering the same issue
Here’s the Github issue:
Although it has seemed to have been fixed in a recent version of MakeCode Arcade.