@@ -2186,7 +2186,7 @@ function up2k_init(subtle) {
2186
2186
st . busy . head . push ( t ) ;
2187
2187
2188
2188
var xhr = new XMLHttpRequest ( ) ;
2189
- xhr . onerror = function ( ) {
2189
+ xhr . onerror = xhr . ontimeout = function ( ) {
2190
2190
console . log ( 'head onerror, retrying' , t . name , t ) ;
2191
2191
if ( ! toast . visible )
2192
2192
toast . warn ( 9.98 , L . u_enethd + "\n\nfile: " + t . name , t ) ;
@@ -2230,6 +2230,7 @@ function up2k_init(subtle) {
2230
2230
try { orz ( e ) ; } catch ( ex ) { vis_exh ( ex + '' , 'up2k.js' , '' , '' , ex ) ; }
2231
2231
} ;
2232
2232
2233
+ xhr . timeout = 34000 ;
2233
2234
xhr . open ( 'HEAD' , t . purl + uricom_enc ( t . name ) , true ) ;
2234
2235
xhr . send ( ) ;
2235
2236
}
@@ -2255,7 +2256,7 @@ function up2k_init(subtle) {
2255
2256
console . log ( "sending keepalive handshake" , t . name , t ) ;
2256
2257
2257
2258
var xhr = new XMLHttpRequest ( ) ;
2258
- xhr . onerror = function ( ) {
2259
+ xhr . onerror = xhr . ontimeout = function ( ) {
2259
2260
if ( t . t_busied != me ) // t.done ok
2260
2261
return console . log ( 'zombie handshake onerror' , t . name , t ) ;
2261
2262
@@ -2512,6 +2513,7 @@ function up2k_init(subtle) {
2512
2513
2513
2514
xhr . open ( 'POST' , t . purl , true ) ;
2514
2515
xhr . responseType = 'text' ;
2516
+ xhr . timeout = 42000 ;
2515
2517
xhr . send ( JSON . stringify ( req ) ) ;
2516
2518
}
2517
2519
@@ -2631,15 +2633,21 @@ function up2k_init(subtle) {
2631
2633
btot = Math . floor ( st . bytes . total / 1024 / 1024 ) ;
2632
2634
2633
2635
xhr . upload . onprogress = function ( xev ) {
2634
- var nb = xev . loaded ;
2635
- st . bytes . inflight += nb - xhr . bsent ;
2636
+ var nb = xev . loaded ,
2637
+ db = nb - xhr . bsent ;
2638
+
2639
+ if ( ! db )
2640
+ return ;
2641
+
2642
+ st . bytes . inflight += db ;
2636
2643
xhr . bsent = nb ;
2644
+ xhr . timeout = 64000 + Date . now ( ) - xhr . t0 ;
2637
2645
pvis . prog ( t , pcar , nb ) ;
2638
2646
} ;
2639
2647
xhr . onload = function ( xev ) {
2640
2648
try { orz ( xhr ) ; } catch ( ex ) { vis_exh ( ex + '' , 'up2k.js' , '' , '' , ex ) ; }
2641
2649
} ;
2642
- xhr . onerror = function ( xev ) {
2650
+ xhr . onerror = xhr . ontimeout = function ( xev ) {
2643
2651
if ( crashed )
2644
2652
return ;
2645
2653
@@ -2666,6 +2674,8 @@ function up2k_init(subtle) {
2666
2674
xhr . overrideMimeType ( 'Content-Type' , 'application/octet-stream' ) ;
2667
2675
2668
2676
xhr . bsent = 0 ;
2677
+ xhr . t0 = Date . now ( ) ;
2678
+ xhr . timeout = 42000 ;
2669
2679
xhr . responseType = 'text' ;
2670
2680
xhr . send ( t . fobj . slice ( car , cdr ) ) ;
2671
2681
}
0 commit comments