edge
edge copied to clipboard
Unresolved JavaScript Promises can terminate the CLR hosting process
If some bad JavaScript code (e.g. unresolved Promises) gets executed, there's a NullReferenceException
being thrown from the Edge.NodeStart
call, and that exception doesn't seem to be able to get caught:
e.ExceptionObject
{"Object reference not set to an instance of an object."}
Data: {System.Collections.ListDictionaryInternal}
HResult: -2147467261
HelpLink: null
InnerException: null
Message: "Object reference not set to an instance of an object."
Source: "edge"
StackTrace: "
at NodejsFuncInvokeContext.CompleteWithError(Exception exception)\r\n
at NodejsFuncInvokeContext.CompleteWithResult(Handle<v8::Value> result)\r\n
at v8FuncCallback(Handle<v8::Value>* , Arguments* args)"
TargetSite: {Void CompleteWithError(System.Exception)}
This brings down the whole CLR process (e.g. IIS) which is really unacceptable. Even if I put a try-catch
block around the code that calls into Edge, or around the Edge.NodeStart
call the process still terminates.
In terms of pseudo-code, something like this causes Edge to throw the above exception, and the whole CLR process and IIS are terminated!
e.sendEmail().then(function(result) {
e.returnValue = result;
// No callback, that's on purpose.
});
// Instead, do the callback here, which
// means when the promise completes the
// callback has already being called.
callback(null, {});