YouTube keeps crashing on Safari

It’s been a while since YouTube has been crashing while playing long videos on Safari. In particular, a noisy grey screen appears with the error message “An error has occurred, please try again later”.

This is very annoying as the only thing I can do is refresh the webpage and start the video again.

Is there a solution to this issue?

(I am using Safari on a MacBook Pro with MacOS Mojave 10.14.1)