[PR #158] [MERGED] Add error handling for failed contact loading in sync.ts #188

Closed
opened 2026-02-27 04:59:29 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/guyzyl/whatsapp-contact-sync/pull/158
Author: @guyzyl
Created: 4/26/2024
Status: Merged
Merged: 4/26/2024
Merged by: @guyzyl

Base: mainHead: handle-contacts-loading-error


📝 Commits (1)

  • 730e940 Add error handling for failed contact loading in sync.ts

📊 Changes

3 files changed (+46 additions, -14 deletions)

View changed files

📝 interfaces/api.ts (+1 -0)
📝 server/src/sync.ts (+19 -6)
📝 web/src/pages/Sync.vue (+26 -8)

📄 Description

This should handle the following error (causing the backend to crash):

/app/server/node_modules/gaxios/build/src/gaxios.js:142
                throw new common_1.GaxiosError(`Request failed with status code ${translatedResponse.status}`, opts, translatedResponse);
                      ^
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {"
    at Gaxios._request (/app/server/node_modules/gaxios/build/src/gaxios.js:142:23)
"GaxiosError: Login Required.
  config: {
    url: 'https://people.googleapis.com/v1/people/me/connections?pageSize=250&personFields=names%2CemailAddresses%2CphoneNumbers%2Cphotos&pageToken=',
    method: 'GET',
    userAgentDirectives: [
      {
        product: 'google-api-nodejs-client',
        version: '7.0.1',
        comment: 'gzip'
      }
    ],
    paramsSerializer: [Function (anonymous)],
    headers: {
      'x-goog-api-client': 'gdcl/7.0.1 gl-node/21.7.3',
      'Accept-Encoding': 'gzip',
      'User-Agent': 'google-api-nodejs-client/7.0.1 (gzip)'
    },
    params: {
      pageSize: 250,
      personFields: 'names,emailAddresses,phoneNumbers,photos',
      pageToken: ''
    },
    validateStatus: [Function (anonymous)],
    retry: true,
    responseType: 'unknown',
    errorRedactor: [Function: defaultErrorRedactor],
    retryConfig: {
      currentRetryAttempt: 0,
      retry: 3,
      httpMethodsToRetry: [ 'GET', 'HEAD', 'PUT', 'OPTIONS', 'DELETE' ],
      noResponseRetries: 2,
      statusCodesToRetry: [ [ 100, 199 ], [ 429, 429 ], [ 500, 599 ] ]
    }
  },
  response: {
    config: {
      url: 'https://people.googleapis.com/v1/people/me/connections?pageSize=250&personFields=names%2CemailAddresses%2CphoneNumbers%2Cphotos&pageToken=',
      method: 'GET',
      userAgentDirectives: [
        {
          product: 'google-api-nodejs-client',
          version: '7.0.1',
          comment: 'gzip'
        }
      ],
      paramsSerializer: [Function (anonymous)],
      headers: {
        'x-goog-api-client': 'gdcl/7.0.1 gl-node/21.7.3',
        'Accept-Encoding': 'gzip',
        'User-Agent': 'google-api-nodejs-client/7.0.1 (gzip)'
      },
      params: {
        pageSize: 250,
        personFields: 'names,emailAddresses,phoneNumbers,photos',
        pageToken: ''
      },
      validateStatus: [Function (anonymous)],
      retry: true,
      responseType: 'unknown',
      errorRedactor: [Function: defaultErrorRedactor]
    },
    data: {
      error: {
        code: 401,
        message: 'Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.',
        errors: [
          {
            message: 'Login Required.',
            domain: 'global',
            reason: 'required',
            location: 'Authorization',
            locationType: 'header'
          }
        ],
        status: 'UNAUTHENTICATED',
        details: [
          {
            '@type': 'type.googleapis.com/google.rpc.ErrorInfo',
            reason: 'CREDENTIALS_MISSING',
            domain: 'googleapis.com',
            metadata: [Object]
          }
        ]
      }
    },
    headers: {
      'alt-svc': 'h3=":443"; ma=2592000',
      'cache-control': 'private',
      'content-encoding': 'gzip',
      'content-type': 'application/json; charset=UTF-8',
      date: 'Fri, 26 Apr 2024 01:24:40 GMT',
      server: 'ESF',
      'transfer-encoding': 'chunked',
      vary: 'Origin, X-Origin, Referer',
      'www-authenticate': 'Bearer realm="https://accounts.google.com/"',
      'x-content-type-options': 'nosniff',
      'x-frame-options': 'SAMEORIGIN',
      'x-xss-protection': '0'
    },
    status: 401,
    statusText: 'Unauthorized',
    request: {
      responseURL: 'https://people.googleapis.com/v1/people/me/connections?pageSize=250&personFields=names%2CemailAddresses%2CphoneNumbers%2Cphotos&pageToken='
    }
  },
  error: undefined,
  status: 401,
  code: 401,
  errors: [
    {
      message: 'Login Required.',
      domain: 'global',
      reason: 'required',
      location: 'Authorization',
      locationType: 'header'
    }
  ],
  [Symbol(gaxios-gaxios-error)]: '6.2.0'
}

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/guyzyl/whatsapp-contact-sync/pull/158 **Author:** [@guyzyl](https://github.com/guyzyl) **Created:** 4/26/2024 **Status:** ✅ Merged **Merged:** 4/26/2024 **Merged by:** [@guyzyl](https://github.com/guyzyl) **Base:** `main` ← **Head:** `handle-contacts-loading-error` --- ### 📝 Commits (1) - [`730e940`](https://github.com/guyzyl/whatsapp-contact-sync/commit/730e94009a46062557f237534fb4808dad3571b5) Add error handling for failed contact loading in sync.ts ### 📊 Changes **3 files changed** (+46 additions, -14 deletions) <details> <summary>View changed files</summary> 📝 `interfaces/api.ts` (+1 -0) 📝 `server/src/sync.ts` (+19 -6) 📝 `web/src/pages/Sync.vue` (+26 -8) </details> ### 📄 Description This should handle the following error (causing the backend to crash): ``` /app/server/node_modules/gaxios/build/src/gaxios.js:142 throw new common_1.GaxiosError(`Request failed with status code ${translatedResponse.status}`, opts, translatedResponse); ^ at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {" at Gaxios._request (/app/server/node_modules/gaxios/build/src/gaxios.js:142:23) "GaxiosError: Login Required. config: { url: 'https://people.googleapis.com/v1/people/me/connections?pageSize=250&personFields=names%2CemailAddresses%2CphoneNumbers%2Cphotos&pageToken=', method: 'GET', userAgentDirectives: [ { product: 'google-api-nodejs-client', version: '7.0.1', comment: 'gzip' } ], paramsSerializer: [Function (anonymous)], headers: { 'x-goog-api-client': 'gdcl/7.0.1 gl-node/21.7.3', 'Accept-Encoding': 'gzip', 'User-Agent': 'google-api-nodejs-client/7.0.1 (gzip)' }, params: { pageSize: 250, personFields: 'names,emailAddresses,phoneNumbers,photos', pageToken: '' }, validateStatus: [Function (anonymous)], retry: true, responseType: 'unknown', errorRedactor: [Function: defaultErrorRedactor], retryConfig: { currentRetryAttempt: 0, retry: 3, httpMethodsToRetry: [ 'GET', 'HEAD', 'PUT', 'OPTIONS', 'DELETE' ], noResponseRetries: 2, statusCodesToRetry: [ [ 100, 199 ], [ 429, 429 ], [ 500, 599 ] ] } }, response: { config: { url: 'https://people.googleapis.com/v1/people/me/connections?pageSize=250&personFields=names%2CemailAddresses%2CphoneNumbers%2Cphotos&pageToken=', method: 'GET', userAgentDirectives: [ { product: 'google-api-nodejs-client', version: '7.0.1', comment: 'gzip' } ], paramsSerializer: [Function (anonymous)], headers: { 'x-goog-api-client': 'gdcl/7.0.1 gl-node/21.7.3', 'Accept-Encoding': 'gzip', 'User-Agent': 'google-api-nodejs-client/7.0.1 (gzip)' }, params: { pageSize: 250, personFields: 'names,emailAddresses,phoneNumbers,photos', pageToken: '' }, validateStatus: [Function (anonymous)], retry: true, responseType: 'unknown', errorRedactor: [Function: defaultErrorRedactor] }, data: { error: { code: 401, message: 'Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.', errors: [ { message: 'Login Required.', domain: 'global', reason: 'required', location: 'Authorization', locationType: 'header' } ], status: 'UNAUTHENTICATED', details: [ { '@type': 'type.googleapis.com/google.rpc.ErrorInfo', reason: 'CREDENTIALS_MISSING', domain: 'googleapis.com', metadata: [Object] } ] } }, headers: { 'alt-svc': 'h3=":443"; ma=2592000', 'cache-control': 'private', 'content-encoding': 'gzip', 'content-type': 'application/json; charset=UTF-8', date: 'Fri, 26 Apr 2024 01:24:40 GMT', server: 'ESF', 'transfer-encoding': 'chunked', vary: 'Origin, X-Origin, Referer', 'www-authenticate': 'Bearer realm="https://accounts.google.com/"', 'x-content-type-options': 'nosniff', 'x-frame-options': 'SAMEORIGIN', 'x-xss-protection': '0' }, status: 401, statusText: 'Unauthorized', request: { responseURL: 'https://people.googleapis.com/v1/people/me/connections?pageSize=250&personFields=names%2CemailAddresses%2CphoneNumbers%2Cphotos&pageToken=' } }, error: undefined, status: 401, code: 401, errors: [ { message: 'Login Required.', domain: 'global', reason: 'required', location: 'Authorization', locationType: 'header' } ], [Symbol(gaxios-gaxios-error)]: '6.2.0' } ``` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-27 04:59:29 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/whatsapp-contact-sync#188
No description provided.