Class method that uses setTimeout() and setInterval() works unexpectedly on repeated calls

tldr: On the first go round lose() works fine but on successive calls, as the player restarts and loses again, retry() is called immediately and msgRepeater() only displays if the user chooses to exit.

When the user loses this node.js game, the class method lose() is called.

lose() first runs another method, msgRepeater(), that repeats a message at intervals for a set period.

Then lose() runs another method, retry(), to prompt the user to restart or exit the game (this runs after a setTimeout() within retry() to allow msgRepeater() to complete first).

On the first go round this works fine but on successive calls, as the player restarts and loses again, retry() is called immediately and the message is only repeated if the user chooses to exit (tho not for as long and accumulated by the number of replays).

Do I have a problem in my approach to setInterval and/or setTimeout? I am stuck and any resolutions would be massively appreciated!

//Retry
retry() {
const retry = () => {
while(this.gameOver && !this.exit) {
let input = prompt('Play Again? y/n: ');
if(input===‘y’) {
this.play();
}
else if(input===‘n’) {
this.exit=true;
}
else {
console.log(
'I don’t understand,\ndo you want to play again? y/n: ’
)
};
}
}
setTimeout(retry, 5000);
};

//Repeated Message
msgRepeater(text) {
const newMsg = () => console.log(text);
const msgInterval = setInterval(newMsg, 400);
const endMsgInterval = () => {
clearInterval(msgInterval);
}
setTimeout(endMsgInterval, 4000);
}

//Lose
lose() {
this.msgRepeater(‘You Lose!’);
this.retry();
}