67
67
/* 0 */
68
68
/***/ ( function ( module , exports ) {
69
69
70
- var g ;
71
-
72
- // This works in non-strict mode
73
- g = ( function ( ) {
74
- return this ;
75
- } ) ( ) ;
76
-
77
- try {
78
- // This works if eval is allowed (see CSP)
79
- g = g || Function ( "return this" ) ( ) || ( 1 , eval ) ( "this" ) ;
80
- } catch ( e ) {
81
- // This works if the window reference is available
82
- if ( typeof window === "object" )
83
- g = window ;
84
- }
85
-
86
- // g can still be undefined, but nothing to do about it...
87
- // We return undefined, instead of nothing here, so it's
88
- // easier to handle this case. if(!global) { ...}
89
-
90
- module . exports = g ;
70
+ var g ;
71
+
72
+ // This works in non-strict mode
73
+ g = ( function ( ) {
74
+ return this ;
75
+ } ) ( ) ;
76
+
77
+ try {
78
+ // This works if eval is allowed (see CSP)
79
+ g = g || Function ( "return this" ) ( ) || ( 1 , eval ) ( "this" ) ;
80
+ } catch ( e ) {
81
+ // This works if the window reference is available
82
+ if ( typeof window === "object" )
83
+ g = window ;
84
+ }
85
+
86
+ // g can still be undefined, but nothing to do about it...
87
+ // We return undefined, instead of nothing here, so it's
88
+ // easier to handle this case. if(!global) { ...}
89
+
90
+ module . exports = g ;
91
91
92
92
93
93
/***/ } ) ,
@@ -4675,7 +4675,7 @@ var IncomingMessage = exports.IncomingMessage = function (xhr, response, mode, f
4675
4675
self . url = response . url
4676
4676
self . statusCode = response . status
4677
4677
self . statusMessage = response . statusText
4678
-
4678
+
4679
4679
response . headers . forEach ( function ( header , key ) {
4680
4680
self . headers [ key . toLowerCase ( ) ] = header
4681
4681
self . rawHeaders . push ( key , header )
@@ -4805,7 +4805,7 @@ IncomingMessage.prototype._onXHRProgress = function () {
4805
4805
self . push ( new Buffer ( response ) )
4806
4806
break
4807
4807
}
4808
- // Falls through in IE8
4808
+ // Falls through in IE8
4809
4809
case 'text' :
4810
4810
try { // This will fail when readyState = 3 in IE9. Switch mode and wait for readyState = 4
4811
4811
response = xhr . responseText
@@ -7264,6 +7264,19 @@ function hasBom (buf) {
7264
7264
} )
7265
7265
}
7266
7266
7267
+ /**
7268
+ * Wrap a callback to ensure it can only be called once.
7269
+ */
7270
+ function once ( cb ) {
7271
+ let called = false
7272
+ return ( ...params ) => {
7273
+ if ( ! called ) {
7274
+ called = true
7275
+ cb ( ...params )
7276
+ }
7277
+ }
7278
+ }
7279
+
7267
7280
/**
7268
7281
* Creates a new EventSource object
7269
7282
*
@@ -7423,17 +7436,25 @@ function EventSource (url, eventSourceInitDict) {
7423
7436
} , delay )
7424
7437
}
7425
7438
7439
+ function destroyRequest ( ) {
7440
+ if ( req . destroy ) req . destroy ( )
7441
+ if ( req . xhr && req . xhr . abort ) req . xhr . abort ( )
7442
+ }
7443
+
7426
7444
function connect ( ) {
7427
7445
var urlAndOptions = makeRequestUrlAndOptions ( )
7428
7446
var isSecure = urlAndOptions . options . protocol === 'https:' ||
7429
7447
( urlAndOptions . url && urlAndOptions . url . startsWith ( 'https:' ) )
7430
7448
7449
+ // Each request should be able to fail at most once.
7450
+ const failOnce = once ( failed )
7451
+
7431
7452
var callback = function ( res ) {
7432
7453
// Handle HTTP redirects
7433
7454
if ( res . statusCode === 301 || res . statusCode === 307 ) {
7434
7455
if ( ! res . headers . location ) {
7435
7456
// Server sent redirect response without Location header.
7436
- failed ( { status : res . statusCode , message : res . statusMessage } )
7457
+ failOnce ( { status : res . statusCode , message : res . statusMessage } )
7437
7458
return
7438
7459
}
7439
7460
if ( res . statusCode === 307 ) reconnectUrl = url
@@ -7444,7 +7465,7 @@ function EventSource (url, eventSourceInitDict) {
7444
7465
7445
7466
// Handle HTTP errors
7446
7467
if ( res . statusCode !== 200 ) {
7447
- failed ( { status : res . statusCode , message : res . statusMessage } )
7468
+ failOnce ( { status : res . statusCode , message : res . statusMessage } )
7448
7469
return
7449
7470
}
7450
7471
@@ -7456,13 +7477,13 @@ function EventSource (url, eventSourceInitDict) {
7456
7477
res . on ( 'close' , function ( ) {
7457
7478
res . removeAllListeners ( 'close' )
7458
7479
res . removeAllListeners ( 'end' )
7459
- failed ( )
7480
+ failOnce ( )
7460
7481
} )
7461
7482
7462
7483
res . on ( 'end' , function ( ) {
7463
7484
res . removeAllListeners ( 'close' )
7464
7485
res . removeAllListeners ( 'end' )
7465
- failed ( )
7486
+ failOnce ( )
7466
7487
} )
7467
7488
_emit ( new Event ( 'open' ) )
7468
7489
@@ -7561,12 +7582,14 @@ function EventSource (url, eventSourceInitDict) {
7561
7582
}
7562
7583
7563
7584
req . on ( 'error' , function ( err ) {
7564
- failed ( { message : err . message } )
7585
+ failOnce ( { message : err . message } )
7565
7586
} )
7566
7587
7567
7588
req . on ( 'timeout' , function ( ) {
7568
- failed ( { message : 'Read timeout, received no data in ' + config . readTimeoutMillis +
7589
+ failOnce ( { message : 'Read timeout, received no data in ' + config . readTimeoutMillis +
7569
7590
'ms, assuming connection is dead' } )
7591
+ // Timeout doesn't mean that the request is cancelled, just that it has elapsed the timeout.
7592
+ destroyRequest ( )
7570
7593
} )
7571
7594
7572
7595
if ( req . setNoDelay ) req . setNoDelay ( true )
@@ -7584,8 +7607,9 @@ function EventSource (url, eventSourceInitDict) {
7584
7607
this . _close = function ( ) {
7585
7608
if ( readyState === EventSource . CLOSED ) return
7586
7609
readyState = EventSource . CLOSED
7587
- if ( req . abort ) req . abort ( )
7588
- if ( req . xhr && req . xhr . abort ) req . xhr . abort ( )
7610
+
7611
+ destroyRequest ( )
7612
+
7589
7613
_emit ( new Event ( 'closed' ) )
7590
7614
}
7591
7615
@@ -8711,28 +8735,28 @@ module.exports = CalculateCapacity
8711
8735
/* 33 */
8712
8736
/***/ ( function ( module , exports ) {
8713
8737
8714
- module . exports = function ( module ) {
8715
- if ( ! module . webpackPolyfill ) {
8716
- module . deprecate = function ( ) { } ;
8717
- module . paths = [ ] ;
8718
- // module.parent = undefined by default
8719
- if ( ! module . children ) module . children = [ ] ;
8720
- Object . defineProperty ( module , "loaded" , {
8721
- enumerable : true ,
8722
- get : function ( ) {
8723
- return module . l ;
8724
- }
8725
- } ) ;
8726
- Object . defineProperty ( module , "id" , {
8727
- enumerable : true ,
8728
- get : function ( ) {
8729
- return module . i ;
8730
- }
8731
- } ) ;
8732
- module . webpackPolyfill = 1 ;
8733
- }
8734
- return module ;
8735
- } ;
8738
+ module . exports = function ( module ) {
8739
+ if ( ! module . webpackPolyfill ) {
8740
+ module . deprecate = function ( ) { } ;
8741
+ module . paths = [ ] ;
8742
+ // module.parent = undefined by default
8743
+ if ( ! module . children ) module . children = [ ] ;
8744
+ Object . defineProperty ( module , "loaded" , {
8745
+ enumerable : true ,
8746
+ get : function ( ) {
8747
+ return module . l ;
8748
+ }
8749
+ } ) ;
8750
+ Object . defineProperty ( module , "id" , {
8751
+ enumerable : true ,
8752
+ get : function ( ) {
8753
+ return module . i ;
8754
+ }
8755
+ } ) ;
8756
+ module . webpackPolyfill = 1 ;
8757
+ }
8758
+ return module ;
8759
+ } ;
8736
8760
8737
8761
8738
8762
/***/ } ) ,
@@ -12056,4 +12080,4 @@ module.exports = function isBuffer(arg) {
12056
12080
}
12057
12081
12058
12082
/***/ } )
12059
- /******/ ] ) ;
12083
+ /******/ ] ) ;
0 commit comments