@@ -6987,7 +6987,7 @@ class VwWeconnect extends utils.Adapter {
69876987 return new Promise ( ( resolve ) => setTimeout ( resolve , ms ) ) ;
69886988 }
69896989
6990- async reversePosition ( latitudeValue , longitudeValue , vin ) {
6990+ async reversePosition ( latitudeValue , longitudeValue , vin , retryCount = 0 ) {
69916991 this . log . debug ( "reverse pos started" ) ;
69926992
69936993 request . get (
@@ -7008,10 +7008,20 @@ class VwWeconnect extends utils.Adapter {
70087008 async ( err , resp , body ) => {
70097009 this . log . debug ( "reverse pos received" ) ;
70107010 this . log . debug ( JSON . stringify ( body ) ) ;
7011- if ( err || resp . statusCode >= 400 || ! body ) {
7011+ if ( err || ( resp && resp . statusCode >= 400 ) || ! body ) {
70127012 body && this . log . error ( JSON . stringify ( body ) ) ;
7013- resp && this . log . error ( resp . statusCode . toString ( ) ) ;
7014- err && this . log . error ( err ) ;
7013+ resp && resp . statusCode && this . log . error ( resp . statusCode . toString ( ) ) ;
7014+ if ( err ) {
7015+ this . log . error ( err . message || err . toString ( ) ) ;
7016+ }
7017+ // Retry up to 3 times with increasing delay
7018+ if ( retryCount < 3 ) {
7019+ const delay = ( retryCount + 1 ) * 30000 ; // 30s, 60s, 90s
7020+ this . log . debug ( `Reverse geocoding failed, retry ${ retryCount + 1 } /3 in ${ delay / 1000 } s` ) ;
7021+ setTimeout ( ( ) => {
7022+ this . reversePosition ( latitudeValue , longitudeValue , vin , retryCount + 1 ) ;
7023+ } , delay ) ;
7024+ }
70157025 return ;
70167026 }
70177027 if ( body . display_name ) {
0 commit comments