-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
Package: nodeIssues related to the Sentry Node SDKIssues related to the Sentry Node SDK
Description
- Review the documentation: https://docs.sentry.io/
- Search for existing issues: https://github.com/getsentry/sentry-javascript/issues
- Use the latest release: https://github.com/getsentry/sentry-javascript/releases
Package + Version
-
@sentry/node: 6.13.0+
Description
When https requests behind an http proxy are made, @sentry/node versions 6.13.0+ causes the following error:
TypeError [ERR_INVALID_PROTOCOL]: Protocol "http:" not supported. Expected "https:"
at new ClientRequest (_http_client.js:155:11)
at Object.request (https.js:313:10)
at Object.wrappedMethod [as request] (/Users/.../sentry-test/node_modules/@sentry/node/dist/integrations/http.js:91:18)
at Object.<anonymous> (/Users/.../sentry-test/index.js:20:19)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
at internal/main/run_main_module.js:17:47
Based on the stack-trace, it seems to be a problem with the http integration
Demo Code:
const Sentry = require("@sentry/node");
const https = require("https");
const HttpsProxyAgent = require("https-proxy-agent");
Sentry.init({
dsn: "<DSN_HERE>",
});
const proxy = "http://<PROXY_URL>:3128"; // Please setup a http proxy server for this
const agent = new HttpsProxyAgent(proxy);
const options = {
hostname: "example.com",
port: 443,
path: "/todos",
method: "GET",
agent,
};
const req = https.request(options, (res) => {
console.log(`statusCode: ${res.statusCode}`);
res.on("data", (d) => {
process.stdout.write(d);
});
});
req.on("error", (error) => {
console.error(error);
});
req.end();
Notes
- This is not a problem if proxy is disabled.
- This is not a problem in
@sentry/node6.12.0. Downgrading to that version resolves the issue. - This is a problem with the http integration. Filtering out the http integration, resolves the issue:
Sentry.init({
dsn: "<DSN_HERE>",
integrations: (defaults) =>
defaults.filter((integration) => integration.name !== "Http"),
});
Metadata
Metadata
Assignees
Labels
Package: nodeIssues related to the Sentry Node SDKIssues related to the Sentry Node SDK