@@ -96,11 +96,25 @@ class DownloadTask {
9696 try {
9797 await SSHConnectionPool . getConnection ( host , sshConfig , async ( ) => {
9898 await ssh . connect ( sshConfig ) ;
99+
100+ // Add error handler to prevent unhandled ECONNRESET errors
101+ if ( ssh && ssh . connection ) {
102+ const logger = this . services . getLogger ( ) ;
103+ ssh . connection . on ( 'error' , ( err : Error ) => {
104+ // Catch and log connection errors to prevent process crash
105+ if ( err . message && err . message . includes ( 'ECONNRESET' ) ) {
106+ logger . debug ( 'SSH connection reset' , { host } ) ;
107+ } else {
108+ logger . error ( 'SSH connection error' , err , { host } ) ;
109+ }
110+ } ) ;
111+ }
112+
99113 return ssh ;
100114 } ) ;
101115 } catch ( error ) {
102116 const err = error as Error ;
103- throw new Error (
117+ throw UI . createError (
104118 `Failed to connect to ${ host } \n` +
105119 `[TIP] Check your SSH credentials and key format\n` +
106120 `Error: ${ err . message } `
@@ -255,7 +269,7 @@ class DownloadTask {
255269 database : config . serverVariables . databaseName
256270 } ) ;
257271 } catch ( _e ) {
258- throw new Error (
272+ throw UI . createError (
259273 `Could not retrieve database name from server.\n` +
260274 `Magerun output: ${ output } \n` +
261275 `[TIP] Check if Magerun can connect to the database on the server`
@@ -264,7 +278,7 @@ class DownloadTask {
264278 }
265279
266280 if ( ! config . serverVariables . databaseName ) {
267- throw new Error (
281+ throw UI . createError (
268282 `Database name could not be determined.\n` +
269283 `[TIP] Check server Magento configuration and database connectivity`
270284 ) ;
@@ -507,7 +521,7 @@ class DownloadTask {
507521 clearInterval ( sizeCheckInterval ) ;
508522
509523 if ( result . code && result . code !== 0 ) {
510- throw new Error (
524+ throw UI . createError (
511525 `Database dump failed\n[TIP] Check database permissions and disk space\nError: ${ result . stderr } `
512526 ) ;
513527 }
@@ -628,7 +642,7 @@ class DownloadTask {
628642 rsync . on ( 'exit' , function ( code : any ) {
629643 if ( code !== 0 ) {
630644 reject (
631- new Error (
645+ UI . createError (
632646 `Download failed with code ${ code } \n[TIP] Check SSH connection and file permissions`
633647 )
634648 ) ;
@@ -711,13 +725,13 @@ class DownloadTask {
711725 } ) ;
712726 }
713727 } ) . catch ( ( error : any ) => {
714- throw new Error (
728+ throw UI . createError (
715729 `Could not read wp-config.php from server\n[TIP] Make sure WordPress is installed in wp/, blog/, or wordpress/ folder\nError: ${ error . message } `
716730 ) ;
717731 } ) ;
718732
719733 if ( ! config . wordpressConfig . database ) {
720- throw new Error (
734+ throw UI . createError (
721735 `Could not parse WordPress database configuration from wp-config.php\n[TIP] Check if wp-config.php is properly formatted`
722736 ) ;
723737 }
@@ -766,7 +780,7 @@ class DownloadTask {
766780
767781 await ssh . execCommand ( dumpCommand ) . then ( function ( result : any ) {
768782 if ( result . code && result . code !== 0 ) {
769- throw new Error (
783+ throw UI . createError (
770784 `WordPress database dump failed\n[TIP] Check WordPress database credentials and permissions\nError: ${ result . stderr } `
771785 ) ;
772786 }
0 commit comments