-
Notifications
You must be signed in to change notification settings - Fork 215
Open
Labels
Description
Hi,
It looks that erros happening in asynchronous functions somehow lose their stack.
Please check this minimal reproducible case:
load_module modules/ngx_http_js_module.so;
events {
worker_connections 1024;
}
http {
js_import err.js;
server {
location = /testAsync {
js_content err.testAsync;
}
location = /testSync {
js_content err.testSync;
}
}
}
The content of err.js is:
async function testAsync(r) {
try {
await ngx.fetch('http://127.0.0.1:12345');
} catch(e) {
r.return(200, `message: ${e.message}\nstack: ${e.stack}\n`);
}
}
function testSync(r) {
try {
throw Error('oops');
} catch(e) {
r.return(200, `message: ${e.message}\nstack: ${e.stack}\n`);
}
}
export default { testAsync, testSync }
This first result seems perfectly fine:
% curl 127.1/testSync
message: oops
stack: Error: oops
at testSync (/conf/err.js:11)
But the second doesn't look so good:
% curl 127.1/testAsync
message: connect failed
stack: undefined
Please feel free to reach out to me for any additional details you may require.
Thank you in advance.