The limit is 30s of runtime on the server instance, according to this post. I don’t know how to check it in advance, but one thing that I’ve been doing is placing userAgent guards like this:
if (navigator.userAgent.match('HeadlessChrome'))
return;
// rest of cell follows...
at the beginning of long-running cells. I got the idea from @mootari’s notebook: