To avoid confusing errors in stack traces, we would re-run compiled code if it error-ed to avoid syntax errors on lines that don't exist.
This caused the following code to run twice since "compile" in nodejs is "compile and run."
console.log('hi');
throw new Error('blah');
Since the only errors we care about are syntax errors, we'll instead use compileFunction from vm to validate the syntax - if it fails, we'll compile the original code (to get an appropriate error); otherwise we'll compile the code with our footer (at this point we don't care if the code fails since the callsites will be on the correct lines).
https://app.asana.com/0/0/1202058950801330
To avoid confusing errors in stack traces, we would re-run compiled code if it error-ed to avoid syntax errors on lines that don't exist.
This caused the following code to run twice since "compile" in nodejs is "compile and run."
Since the only errors we care about are syntax errors, we'll instead use
compileFunction
fromvm
to validate the syntax - if it fails, we'll compile the original code (to get an appropriate error); otherwise we'll compile the code with our footer (at this point we don't care if the code fails since the callsites will be on the correct lines).