@@ -690,6 +690,8 @@ function pyInputSetScrollTop(st) {
690690}
691691
692692
693+ var num414Tries = 0 ; // hacky global
694+
693695// run at the END so that everything else can be initialized first
694696function genericOptFrontendReady ( ) {
695697 initTogetherJS ( ) ; // initialize early
@@ -866,7 +868,23 @@ function genericOptFrontendReady() {
866868
867869 Note that you'll probably need to customize this check for your server. */
868870 if ( jqxhr && jqxhr . responseText . indexOf ( '414' ) >= 0 ) {
869- setFronendError ( [ "Server error! Your code might be too long for this tool. Shorten your code and re-try." ] ) ;
871+
872+ // ok this is an UBER UBER hack. If this happens just once, then
873+ // force click the "Visualize Execution" button again and re-try.
874+ // why? what's the difference the second time around? the diffs_json
875+ // parameter (derived from deltaObj) will be *empty* the second time
876+ // around since it gets reset on every execution. if diffs_json is
877+ // HUGE, then that might force the URL to be too big without your
878+ // code necessarily being too big, so give it a second shot with an
879+ // empty diffs_json. if it STILL fails, then display the error
880+ // message and give up.
881+ if ( num414Tries === 0 ) {
882+ num414Tries ++ ;
883+ $ ( "#executeBtn" ) . click ( ) ;
884+ } else {
885+ num414Tries = 0 ;
886+ setFronendError ( [ "Server error! Your code might be too long for this tool. Shorten your code and re-try." ] ) ;
887+ }
870888 } else {
871889 setFronendError ( [ "Server error! Your code might be taking too much time to run or using too much memory." ,
872890 "Also, this tool does not work on raw_input(), input() and bytearray() in some cases." ,
0 commit comments