File tree Expand file tree Collapse file tree 1 file changed +8
-5
lines changed
lib/plugins/event_dispatcher Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -51,19 +51,22 @@ export const dispatchEvent = function(
51
51
} ,
52
52
} ;
53
53
54
+ const reqWrapper : { req ?: http . ClientRequest } = { } ;
55
+
54
56
const requestCallback = function ( response ?: { statusCode : number } ) : void {
55
57
if ( response && response . statusCode && response . statusCode >= 200 && response . statusCode < 400 ) {
58
+ reqWrapper . req ?. destroy ( ) ;
56
59
callback ( response ) ;
57
60
}
58
61
} ;
59
62
60
- const req = ( parsedUrl . protocol === 'http:' ? http : https )
63
+ reqWrapper . req = ( parsedUrl . protocol === 'http:' ? http : https )
61
64
. request ( requestOptions , requestCallback as ( res : http . IncomingMessage ) => void ) ;
62
65
// Add no-op error listener to prevent this from throwing
63
- req . on ( 'error' , function ( ) { } ) ;
64
- req . write ( dataString ) ;
65
- req . end ( ) ;
66
- return req ;
66
+ reqWrapper . req . on ( 'error' , function ( ) { } ) ;
67
+ reqWrapper . req . write ( dataString ) ;
68
+ reqWrapper . req . end ( ) ;
69
+ return reqWrapper . req ;
67
70
} ;
68
71
69
72
export default {
You can’t perform that action at this time.
0 commit comments