@@ -29,14 +29,25 @@ class ResponsesQueue {
29
29
page . on ( "response" , function callback ( resp ) {
30
30
if ( resp . url ( ) . includes ( url ) ) {
31
31
console . log ( ( new Date ) . toUTCString ( ) , "-- Queued response received" , resp . url ( ) , ":" ) ;
32
- resp . json ( ) . then ( data => {
33
- that . __respReceivedQueue [ url ] = data ;
32
+ console . log ( resp . status ( ) ) ;
33
+ if ( resp . status ( ) === 204 ) {
34
+ that . __respReceivedQueue [ url ] = "ok" ;
34
35
page . removeListener ( "response" , callback ) ;
35
36
const index = respPendingQueue . indexOf ( url ) ;
36
37
if ( index > - 1 ) {
37
38
respPendingQueue . splice ( index , 1 ) ;
38
39
}
39
- } ) ;
40
+ }
41
+ else {
42
+ resp . json ( ) . then ( data => {
43
+ that . __respReceivedQueue [ url ] = data ;
44
+ page . removeListener ( "response" , callback ) ;
45
+ const index = respPendingQueue . indexOf ( url ) ;
46
+ if ( index > - 1 ) {
47
+ respPendingQueue . splice ( index , 1 ) ;
48
+ }
49
+ } ) ;
50
+ }
40
51
}
41
52
} ) ;
42
53
}
@@ -60,11 +71,9 @@ class ResponsesQueue {
60
71
if ( sleptFor >= timeout ) {
61
72
throw ( "-- Timeout reached." + new Date ( ) . toUTCString ( ) ) ;
62
73
}
63
- // console.log("waitUntilResponse", url);
64
- // console.log(Object.keys(this.__respReceivedQueue));
65
74
if ( Object . prototype . hasOwnProperty . call ( this . __respReceivedQueue , url ) ) {
66
75
const resp = this . __respReceivedQueue [ url ] ;
67
- if ( resp && "error" in resp && resp [ "error" ] !== null ) {
76
+ if ( resp && Object . prototype . hasOwnProperty . call ( resp , "error" ) && resp [ "error" ] !== null ) {
68
77
throw ( "-- Error in response" , resp [ "error" ] ) ;
69
78
}
70
79
delete this . __respReceivedQueue [ url ] ;
0 commit comments