File tree Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -121,6 +121,9 @@ class ActionRequest {
121
121
if ( url ) {
122
122
winston . info ( `[stream] beginning stream via download url` , this . logInfo ) ;
123
123
let hasResolved = false ;
124
+ // Here we can cork the stream and uncork if we receive a 200 OK response
125
+ // If we do not receive a 200 we do not want to allow data to pipe and ignore a non-200 response
126
+ stream . cork ( ) ;
124
127
httpRequest
125
128
. get ( url , { timeout } )
126
129
. on ( "error" , ( err ) => {
@@ -137,7 +140,11 @@ class ActionRequest {
137
140
}
138
141
} )
139
142
. on ( "response" , ( response ) => {
140
- if ( response . statusCode !== 200 ) {
143
+ if ( response . statusCode === 200 ) {
144
+ // Stop buffering in memory and allow action to send data
145
+ stream . uncork ( ) ;
146
+ }
147
+ else {
141
148
winston . warn ( `[stream] There was an error received from Looker.` +
142
149
`ErrorCode: ${ response . statusCode } ErrorMessage: ${ response . statusMessage } ` , this . logInfo ) ;
143
150
if ( ! hasResolved ) {
Original file line number Diff line number Diff line change @@ -191,6 +191,9 @@ export class ActionRequest {
191
191
if ( url ) {
192
192
winston . info ( `[stream] beginning stream via download url` , this . logInfo )
193
193
let hasResolved = false
194
+ // Here we can cork the stream and uncork if we receive a 200 OK response
195
+ // If we do not receive a 200 we do not want to allow data to pipe and ignore a non-200 response
196
+ stream . cork ( )
194
197
httpRequest
195
198
. get ( url , { timeout} )
196
199
. on ( "error" , ( err ) => {
@@ -206,7 +209,10 @@ export class ActionRequest {
206
209
}
207
210
} )
208
211
. on ( "response" , ( response ) => {
209
- if ( response . statusCode !== 200 ) {
212
+ if ( response . statusCode === 200 ) {
213
+ // Stop buffering in memory and allow action to send data
214
+ stream . uncork ( )
215
+ } else {
210
216
winston . warn ( `[stream] There was an error received from Looker.` +
211
217
`ErrorCode: ${ response . statusCode } ErrorMessage: ${ response . statusMessage } ` , this . logInfo )
212
218
if ( ! hasResolved ) {
You can’t perform that action at this time.
0 commit comments