File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -40,6 +40,7 @@ export class Watch {
4040 const controller = new AbortController ( ) ;
4141 requestInit . signal = controller . signal as AbortSignal ;
4242 requestInit . method = 'GET' ;
43+ requestInit . timeout = 30000 ;
4344
4445 let doneCalled : boolean = false ;
4546 const doneCallOnce = ( err : any ) => {
@@ -53,6 +54,15 @@ export class Watch {
5354 try {
5455 const response = await fetch ( watchURL , requestInit ) ;
5556
57+ // Enable socket keep-alive to prevent connection stalls
58+ if ( requestInit . agent && typeof requestInit . agent === 'object' ) {
59+ for ( const socket of Object . values ( requestInit . agent . sockets ) . flat ( ) ) {
60+ if ( socket ) {
61+ socket . setKeepAlive ( true , 30000 ) ;
62+ }
63+ }
64+ }
65+
5666 if ( response . status === 200 ) {
5767 response . body . on ( 'error' , doneCallOnce ) ;
5868 response . body . on ( 'close' , ( ) => doneCallOnce ( null ) ) ;
You can’t perform that action at this time.
0 commit comments