fix: stop user code after 500ms of execution

Code like `var xs = []; while(true){ xs.push(1) }` can quickly run the
browser out of memory causing it to crash.  These changes stop user loops
from running indefinitely so that common mistakes will no longer cause
the browser to crash.

Also, the user is informed if a long running loop is detected (js and
jsx challenges) during preview or testing.  Before this there was no
protection for js challenges and no information was given to the
user if they had created such a loop.

Co-Authored-By: Tom <20648924+moT01@users.noreply.github.com>
Co-Authored-By: mrugesh <1884376+raisedadead@users.noreply.github.com>
Co-Authored-By: Randell Dawson <5313213+RandellDawson@users.noreply.github.com>
This commit is contained in:
Oliver Eyton-Williams
2019-11-27 02:51:43 +01:00
committed by mrugesh
parent 1a56f4d5f4
commit f5feff386a
5 changed files with 83 additions and 39 deletions
+1 -1
View File
@@ -14,6 +14,7 @@
"@fortawesome/free-regular-svg-icons": "^5.11.2",
"@fortawesome/free-solid-svg-icons": "^5.11.2",
"@fortawesome/react-fontawesome": "^0.1.4",
"@freecodecamp/loop-protect": "^2.2.1",
"@freecodecamp/react-bootstrap": "^0.32.3",
"@reach/router": "^1.2.1",
"algoliasearch": "^3.35.1",
@@ -40,7 +41,6 @@
"gatsby-transformer-remark": "^2.6.30",
"jquery": "^3.4.1",
"lodash": "^4.17.15",
"loop-protect": "^2.1.6",
"monaco-editor": "^0.18.1",
"monaco-editor-webpack-plugin": "^1.7.0",
"nanoid": "^1.2.2",