-
Notifications
You must be signed in to change notification settings - Fork 686
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Don't immediately return promise within newly created promise #807
Don't immediately return promise within newly created promise #807
Conversation
be47463
to
a880c20
Compare
setTimeout(function () { | ||
resolve(result); | ||
}, 0); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it normal that rejection of launch promise is not handled here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's intended that rejection will be propagated to the caller, which is in server.ts here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there is no reject callback AND the "launch" promise is not returned anywhere, I'm quite sure that the error will be silent.
This should be the correct way to bubble the error to the caller:
launch(details).then(result => {
// async error - when target not not ENEOT
result.process.on('error', reject);
// success after a short freeing event loop
setTimeout(function () {
resolve(result);
}, 0);
}).catch(reject);
return Promise.resolve({ | ||
process, | ||
command: details.serverPath, | ||
usingMono: false | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not putting all the code in a Promise like previously?
Any error there will end up in a throw which is not really what a function returning a promise should do.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any exceptions should ultimately be propagated to the caller in server.ts. The catch()
there handles all rejections and exceptions.
Fixes #804