fix: sendRequest doesnt return error in some cases - INS-1262 - #9059
Conversation
|
Seems there's some boilerplate code. Could we make the code simpler? like: const promise = new Promise<Response | undefined>(async (resolve, reject) => {
try {
// ...
resolve(result);
} catch (e) {
// ...
reject(e);
}
})
if(cb) {
try {
const result = await promise;
cb(undefined, result);
} catch(e) {
cb(e);
}
}
return promise; |
Cool, will refactor it a bit. |
jackkav
left a comment
There was a problem hiding this comment.
This promise callback is an async function, why not just await the response? why use these promise then chains? Very difficult to understand error cases.
|
@jackkav Firstly I agreed that await the response is more reasonable, there's background of it, we digged into this before, as the existing interface which only supports callback, which doesn't require |
Changes
requestToCurlOptionsalways returns request body mime type as the body could be emptyTested cases from: #9031 #8897