Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@sentry/node v7.46.0 affects got github responses #7724

Closed
3 tasks done
avaly opened this issue Apr 4, 2023 · 3 comments · Fixed by #7740
Closed
3 tasks done

@sentry/node v7.46.0 affects got github responses #7724

avaly opened this issue Apr 4, 2023 · 3 comments · Fixed by #7740

Comments

@avaly
Copy link

avaly commented Apr 4, 2023

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using? If you use the CDN bundles, please specify the exact bundle (e.g. bundle.tracing.min.js) in your SDK setup.

@sentry/node

SDK Version

7.46.0

Framework Version

No response

Link to Sentry event

No response

SDK Setup

Sentry.init({
  dsn: process.env.SENTRY_DSN
});

Steps to Reproduce

  1. Use node.js v18
  2. Add got v11.8.0 (pre ESM versions)
  3. Initialize Sentry v7.46.0
  4. Make a Github API request for a private repository with got (the private repository part is important - public repositories are not affected)
const Sentry = require('@sentry/node');
const got = require('got');

(async () => {
  Sentry.init({
    dsn: process.env.SENTRY_DSN
  });

  try {
    const response = await got('https://api.github.com/repos/OWNER/REPO/commits?per_page=1', {
      password: process.env.GITHUB_TOKEN
    })
    console.log(response.body);
  } catch (err) {
    console.error(err);
  }
})();

Downgrading @sentry/node to 7.45.0 makes the result expected.

Expected Result

We get a 200 response back from got.

Actual Result

We get a 404 response back from got.

@AbhiPrasad
Copy link
Member

Hey @avaly - I was able to reproduce this issue: https://github.com/AbhiPrasad/GH-7724-node-got-github-responses

@Lms24 since the only thing that changed was because of #7667, could you take a look? Maybe got sets something weird on the authority.

@AbhiPrasad
Copy link
Member

$ node index.js
18.15.0
[
  InboundFilters {
    _options: {},
    name: 'InboundFilters',
    isDefaultInstance: true
  },
  FunctionToString {
    name: 'FunctionToString',
    isDefaultInstance: true
  },
  Console { name: 'Console', isDefaultInstance: true },
  Http {
    name: 'Http',
    _breadcrumbs: true,
    _tracing: undefined,
    isDefaultInstance: true
  },
  OnUncaughtException {
    name: 'OnUncaughtException',
    handler: [Function (anonymous)],
    _options: { exitEvenIfOtherHandlersAreRegistered: true },
    isDefaultInstance: true
  },
  OnUnhandledRejection {
    _options: { mode: 'warn' },
    name: 'OnUnhandledRejection',
    isDefaultInstance: true
  },
  ContextLines {
    _options: {},
    name: 'ContextLines',
    isDefaultInstance: true
  },
  LocalVariables {
    _options: {},
    _session: AsyncSession { _session: [Session] },
    name: 'LocalVariables',
    _cachedFrames: LRUMap {
      size: 0,
      limit: 20,
      newest: undefined,
      oldest: undefined,
      _keymap: Map(0) {}
    },
    isDefaultInstance: true
  },
  Context {
    _options: { app: true, os: true, device: true, culture: true },
    name: 'Context',
    isDefaultInstance: true
  },
  Modules { name: 'Modules', isDefaultInstance: true },
  RequestData {
    name: 'RequestData',
    _addRequestData: [Function: addRequestDataToEvent],
    _options: { include: [Object], transactionNamingScheme: 'methodPath' },
    isDefaultInstance: true
  },
  LinkedErrors {
    name: 'LinkedErrors',
    _key: 'cause',
    _limit: 5,
    isDefaultInstance: true
  }
]
Sentry Logger [log]: Integration installed: Http
{
  timestamp: 1680620629.575,
  category: 'http',
  data: {
    method: 'GET',
    status_code: 404,
    url: 'https://[Filtered]:[Filtered]@api.github.com/repos/abhiprasad/dotfiles/commits',
    'http.query': 'per_page=1'
  },
  type: 'http'
}
HTTPError: Response code 404 (Not Found)
    at Request.<anonymous> (/Users/abhijeetprasad/sdk-demos/node/GH-7724-node-got-github-responses/node_modules/got/dist/source/as-promise/index.js:118:42)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  code: 'ERR_NON_2XX_3XX_RESPONSE',
  timings: {
    start: 1680620629374,
    socket: 1680620629375,
    lookup: 1680620629384,
    connect: 1680620629401,
    secureConnect: 1680620629420,
    upload: 1680620629420,
    response: 1680620629575,
    end: 1680620629577,
    error: undefined,
    abort: undefined,
    phases: {
      wait: 1,
      dns: 9,
      tcp: 17,
      tls: 19,
      request: 0,
      firstByte: 155,
      download: 2,
      total: 203
    }
  }
}

@Lms24
Copy link
Member

Lms24 commented Apr 4, 2023

Hi @avaly, thanks for the report. I opened #7740 to fix this bug. With the fix, @AbhiPrasad's reproduction works for me again. We'll include this fix in the next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants