You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm running Edge.js in an ASPNet (not core) app running in IIS and a JS stack overflow causes the entire process to drop and my site goes down. More clearly:
try{varfunc=EdgeJs.Edge.Func("function x() { x(); }; x()");awaitfunc(null);}catch{Console.log("Error ignored (for this demonstration)");}
If I run this in a standard exe, I see
Error ignored (for this demonstration)
If I do the same in IIS, the entire site immediately goes down.
Investigation
The reason is that running under IIS this causes a stack overflow in the main process rather than just node, and that can't be caught. In IIS the max stacksize is much smaller than a standard unmodified exe.
$ dumpbin.exe /headers my.exe | find "stack"
100000 size of stack reserve
1000 size of stack commit
$ dumpbin.exe /headers w3wp.exe | find "stack"
80000 size of stack reserve
2000 size of stack commit
Measurements are bytes in hex, so 1mb/4kb vs 512kb/8kb. I can patch my exe stack sizes to reproduce the terminal exception in a console app with
so I'm happy this is the issue. (numbers are bytes in decimal)
Possible fix
The thread constructor takes a max stack size, so we can increase it for a single thread without patching the exe.
I've been using a fork of the tjanczuk edge.js for a year or two, patched to set the max stack size for the node thread to 1048576 (1mb) and it has worked well in 32 and 64 bit Windows systems on .Net Framework. I do not know what effect this would have for .Net Core or other platforms.
The text was updated successfully, but these errors were encountered:
I'm running Edge.js in an ASPNet (not core) app running in IIS and a JS stack overflow causes the entire process to drop and my site goes down. More clearly:
If I run this in a standard exe, I see
If I do the same in IIS, the entire site immediately goes down.
Investigation
The reason is that running under IIS this causes a stack overflow in the main process rather than just node, and that can't be caught. In IIS the max stacksize is much smaller than a standard unmodified exe.
Measurements are bytes in hex, so 1mb/4kb vs 512kb/8kb. I can patch my exe stack sizes to reproduce the terminal exception in a console app with
so I'm happy this is the issue. (numbers are bytes in decimal)
Possible fix
The thread constructor takes a max stack size, so we can increase it for a single thread without patching the exe.
I've been using a fork of the tjanczuk edge.js for a year or two, patched to set the max stack size for the node thread to 1048576 (1mb) and it has worked well in 32 and 64 bit Windows systems on .Net Framework. I do not know what effect this would have for .Net Core or other platforms.
The text was updated successfully, but these errors were encountered: