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

feat: HTTP(S) Proxy support for Node #1761

Merged
merged 3 commits into from
Nov 23, 2018
Merged

feat: HTTP(S) Proxy support for Node #1761

merged 3 commits into from
Nov 23, 2018

Conversation

kamilogorek
Copy link
Contributor

@kamilogorek kamilogorek commented Nov 22, 2018

Fixes: #1382

@getsentry-bot
Copy link
Contributor

getsentry-bot commented Nov 22, 2018

Messages
📖 ✅ TSLint passed
📖 @sentry/browser gzip'ed minified size: 20.7676 kB

Generated by 🚫 dangerJS

@kamilogorek
Copy link
Contributor Author

Still need to write some tests around it though.

import { BaseTransport } from './base';

/** Node https module transport */
export class HTTPSTransport extends BaseTransport {
/** Create a new instance and set this.agent */
public constructor(public options: TransportOptions) {
super(options);
this.client = new https.Agent({ keepAlive: true, maxSockets: 100 });
const proxy = options.httpsProxy || options.httpProxy || process.env.https_proxy || process.env.http_proxy;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure about the order making sense here.

Copy link
Contributor Author

@kamilogorek kamilogorek Nov 22, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From our docs:

When set a proxy can be configured that should be used for outbound requests. This is also used for HTTPS requests unless a separate https-proxy is configured.

I think that user specified options should always override env variables, thus order is like this.

@@ -225,9 +225,17 @@ export interface SentryResponse {

/** JSDoc */
export interface TransportOptions {
[key: string]: any;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise we cannot assign httpProxy and friends to transportOptions and I wanted it to be consistent with other SDKs and not ask users to pass it directly there, eg.:

init({
  transportOptions: {
    httpProxy: 'http://something:8008'
  }
})

(which would be a better option imo, but it's not how it works in other SDKs)

@kamilogorek kamilogorek merged commit 4beb6ac into master Nov 23, 2018
@kamilogorek kamilogorek deleted the node-proxy branch November 23, 2018 11:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants