fix(core): update

This commit is contained in:
Philipp Kunz 2022-08-01 17:15:52 +02:00
parent d3d0649b73
commit 5e6f2c6fbf
2 changed files with 9 additions and 5 deletions

View File

@ -3,6 +3,6 @@
*/
export const commitinfo = {
name: '@pushrocks/smartrequest',
version: '2.0.8',
version: '2.0.9',
description: 'dropin replacement for request'
}

View File

@ -98,7 +98,7 @@ export let request = async (
responseStreamArg: boolean = false,
requestDataFunc: (req: plugins.http.ClientRequest) => void = null
): Promise<IExtendedIncomingMessage> => {
const done = plugins.smartpromise.defer<any>();
const done = plugins.smartpromise.defer<IExtendedIncomingMessage>();
// merge options
const defaultOptions: interfaces.ISmartRequestOptions = {
@ -158,7 +158,7 @@ export let request = async (
// lets perform the actual request
const requestToFire = requestModule.request(optionsArg, async (response) => {
if (responseStreamArg) {
done.resolve(response);
done.resolve(response as IExtendedIncomingMessage);
} else {
const builtResponse = await buildUtf8Response(response, optionsArg.autoJsonParse);
done.resolve(builtResponse);
@ -190,6 +190,10 @@ export let request = async (
requestToFire.destroy();
});
const result = await done.promise;
return result;
const response = await done.promise;
response.on('error', (err) => {
console.log(err);
response.destroy();
})
return response;
};