PLhery / node-twitter-api-v2

Strongly typed, full-featured, light, versatile yet powerful Twitter API v1.1 and v2 client for Node.js.
https://www.npmjs.com/package/twitter-api-v2
Apache License 2.0
1.24k stars 174 forks source link

[bug] Occasional Service Unavailable - 503 when posting video or image #499

Open francistogram opened 10 months ago

francistogram commented 10 months ago

Describe the bug We've been posting threads and every once in a while we'll get back a 503, service unavailable error

ApiResponseError: Request failed with code 503
    at RequestHandlerHelper.createResponseError (/var/task/node_modules/twitter-api-v2/dist/cjs/client-mixins/request-handler.helper.js:103:16)
    at RequestHandlerHelper.onResponseEndHandler (/var/task/node_modules/twitter-api-v2/dist/cjs/client-mixins/request-handler.helper.js:252:25)
    at Gunzip.emit (node:events:514:28)
    at endReadableNT (node:internal/streams/readable:1359:12)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
  error: true,
  type: 'response',
  code: 503,
  headers: {
    date: 'Thu, 31 Aug 2023 17:45:05 UTC',
    perf: '7626143928',
    server: 'tsa_b',
    'set-cookie': [
      'guest_id=v1%3A169350390426486385; Max-Age=34214400; Expires=Mon, 30 Sep 2024 17:45:05 GMT; Path=/; Domain=.twitter.com; Secure; SameSite=None'
    ],
    'api-version': '2.66',
    'content-type': 'application/json; charset=utf-8',
    'cache-control': 'no-cache, no-store, max-age=0',
    'content-length': '94',
    'x-access-level': 'read-write',
    'x-frame-options': 'SAMEORIGIN',
    'content-encoding': 'gzip',
    'x-transaction-id': '1ffe80abeab02a67',
    'x-xss-protection': '0',
    'x-rate-limit-limit': '40000',
    'x-rate-limit-reset': '1693504804',
    'content-disposition': 'attachment; filename=json.json',
    'x-content-type-options': 'nosniff',
    'x-rate-limit-remaining': '40000',
    'x-app-limit-24hour-limit': '50',
    'x-app-limit-24hour-reset': '1693587602',
    'strict-transport-security': 'max-age=631138519',
    'x-user-limit-24hour-limit': '50',
    'x-user-limit-24hour-reset': '1693575905',
    'x-app-limit-24hour-remaining': '47',
    'x-user-limit-24hour-remaining': '47',
    'x-response-time': '1028',
    'x-connection-hash': 'a942524660f7ee7aa5ce51cd2e21913f00aa6103b9cf3f8b7c7d75ea2235c78e',
    connection: 'close'
  },
  rateLimit: { limit: 40000, remaining: 40000, reset: 1693504804 },
  data: {
    title: 'Service Unavailable',
    detail: 'Service Unavailable',
    type: 'about:blank',
    status: 503
  }
}

The tweet does actually post but because it's a 503 it's interpreted as a failure and the thread stops posting

To Reproduce I'm actually unable to reproduce consistently as I think it's some kind of Twitter API bug

I wonder if anyone's run into this and figured out how to work around this as I think it's an issue with the Twitter API