@@ -66,9 +66,42 @@ export async function amplifyPushWithRetry(
6666 return ;
6767 } catch ( err ) {
6868 lastError = err instanceof Error ? err : new Error ( String ( err ) ) ;
69+ const isTransient = isTransientError ( lastError ) ;
70+
71+ // Log full error details for debugging HTML/transient errors
72+ console . log ( `[amplifyPushWithRetry] Attempt ${ attempt + 1 } /${ PUSH_MAX_RETRIES + 1 } failed.` ) ;
73+ console . log ( `[amplifyPushWithRetry] Error message: ${ lastError . message } ` ) ;
74+ if ( lastError . stack ) {
75+ console . log ( `[amplifyPushWithRetry] Stack trace: ${ lastError . stack } ` ) ;
76+ }
77+ // Log additional error properties (e.g. AssertionError actual/expected, AWS $response)
78+ try {
79+ const errKeys = Object . keys ( lastError ) . filter ( ( k ) => ! [ 'message' , 'stack' ] . includes ( k ) ) ;
80+ if ( errKeys . length > 0 ) {
81+ const extras : Record < string , any > = { } ;
82+ for ( const key of errKeys ) {
83+ extras [ key ] = ( lastError as any ) [ key ] ;
84+ }
85+ console . log ( `[amplifyPushWithRetry] Additional error properties: ${ JSON . stringify ( extras , null , 2 ) } ` ) ;
86+ }
87+ } catch ( logErr ) {
88+ console . log ( `[amplifyPushWithRetry] Could not serialize error properties: ${ logErr } ` ) ;
89+ }
90+ // Check for AWS SDK raw response
91+ if ( ( err as any ) ?. $response ) {
92+ try {
93+ console . log ( `[amplifyPushWithRetry] Raw $response: ${ JSON . stringify ( ( err as any ) . $response , null , 2 ) } ` ) ;
94+ } catch ( logErr ) {
95+ console . log ( `[amplifyPushWithRetry] $response present but not serializable: ${ logErr } ` ) ;
96+ }
97+ }
98+ // If the error contains HTML content, highlight it for debugging
99+ if ( isTransient && / < ! D O C T Y P E | < h t m l | < b o d y / i. test ( lastError . message ) ) {
100+ console . log ( `[amplifyPushWithRetry] ⚠️ HTML error page detected in CLI output. Full error body above.` ) ;
101+ }
102+
69103 if ( attempt < PUSH_MAX_RETRIES ) {
70104 const delayMs = PUSH_RETRY_BASE_DELAY_MS * Math . pow ( 2 , attempt ) ;
71- const isTransient = isTransientError ( lastError ) ;
72105 console . warn (
73106 `amplifyPush attempt ${ attempt + 1 } /${ PUSH_MAX_RETRIES + 1 } failed${ isTransient ? ' (transient error)' : '' } : ${ lastError . message } . Retrying in ${ delayMs / 1000 } s...` ,
74107 ) ;
@@ -134,6 +167,11 @@ export function amplifyPush(
134167 if ( ! err ) {
135168 resolve ( ) ;
136169 } else {
170+ // Log full CLI output for debugging transient HTML errors (503/504)
171+ console . log ( `[amplifyPush] Push failed. Full error message:\n${ err . message } ` ) ;
172+ if ( / < ! D O C T Y P E | < h t m l | < b o d y | U n e x p e c t e d t o k e n ' < ' / i. test ( err . message ) ) {
173+ console . log ( `[amplifyPush] ⚠️ HTML error page detected in CLI output — likely a transient AWS service error (503/504/rate limit).` ) ;
174+ }
137175 reject ( err ) ;
138176 }
139177 } ) ;
0 commit comments