Skip to content

Truncates stack traces from failed requests #823

@andersk

Description

@andersk

With @octokit/plugin-throttling installed, the stack trace from a failed request does not show the calling function (here outer). This makes it hard to track down where the error originates in a large project.

This is due to the bottleneck library (which seems to be unmaintained, perhaps a replacement should be investigated):

Same issue in @octokit/plugin-retry:

import { Octokit } from "@octokit/rest";
import { throttling } from "@octokit/plugin-throttling";

const MyOctokit = Octokit.plugin(throttling);
const octokit = new MyOctokit({
  throttle: { onRateLimit() {}, onSecondaryRateLimit() {} },
});

async function outer() {
  await octokit.users.getByUsername({
    username: "_invalid",
  });
}

await outer();
GET /users/_invalid - 404 with id E8B8:2F0692:212CD136:222B56AC:6953046F in 269ms
file:///tmp/octokit-test/node_modules/@octokit/request/dist-bundle/index.js:123
    throw new RequestError(toErrorMessage(octokitResponse.data), status, {
          ^

RequestError [HttpError]: Not Found - https://docs.github.com/rest
    at fetchWrapper (file:///tmp/octokit-test/node_modules/@octokit/request/dist-bundle/index.js:123:11)
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
    at async Job.doExecute (/tmp/octokit-test/node_modules/bottleneck/light.js:405:18) {
  status: 404,
  request: {
    method: 'GET',
    url: 'https://api.github.com/users/_invalid',
    headers: {
      accept: 'application/vnd.github.v3+json',
      'user-agent': 'octokit-rest.js/22.0.1 octokit-core.js/7.0.6 Node.js/22'
    },
    request: { hook: [Function: bound bound register] }
  },
  response: {
    url: 'https://api.github.com/users/_invalid',
    status: 404,
    headers: {
      'access-control-allow-origin': '*',
      'access-control-expose-headers': 'ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset',
      'content-encoding': 'gzip',
      'content-length': '101',
      'content-security-policy': "default-src 'none'",
      'content-type': 'application/json; charset=utf-8',
      date: 'Mon, 29 Dec 2025 22:45:03 GMT',
      'referrer-policy': 'origin-when-cross-origin, strict-origin-when-cross-origin',
      server: 'github.com',
      'strict-transport-security': 'max-age=31536000; includeSubdomains; preload',
      vary: 'Accept-Encoding, Accept, X-Requested-With',
      'x-content-type-options': 'nosniff',
      'x-frame-options': 'deny',
      'x-github-api-version-selected': '2022-11-28',
      'x-github-media-type': 'github.v3; format=json',
      'x-github-request-id': 'E8B8:2F0692:212CD136:222B56AC:6953046F',
      'x-ratelimit-limit': '60',
      'x-ratelimit-remaining': '58',
      'x-ratelimit-reset': '1767051566',
      'x-ratelimit-resource': 'core',
      'x-ratelimit-used': '2',
      'x-xss-protection': '0'
    },
    data: {
      message: 'Not Found',
      documentation_url: 'https://docs.github.com/rest',
      status: '404'
    }
  },
  [cause]: undefined
}

Node.js v22.21.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    Status: Up for grabsIssues that are ready to be worked on by anyoneType: BugSomething isn't working as documented

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions