Search code examples
javascriptnode.jsdockererror-handlingsentry

Sentry Logging Error, what's wrong with my config and how can I get more detailed errors from sentry? (Possibly Docker related?)


I recently have been working with Sentry, and I have been having some issues with it.

After many hours of frustration getting it to work, I enabled debug mode to see the output. This is what happens every time:

enter image description here

I have followed the docs step by step on integrating this. I have a file to initialize the logging, and then my index file. Here is my logging initialization file:

const Sentry = require("@sentry/node");
const Tracing = require("@sentry/tracing");

Sentry.init({
  dsn: [REDACTED],
  tracesSampleRate: 1.0,
  attachStacktrace: true,
  debug: true,
  environment: process.env.VERSION
});

module.exports = Sentry

From there, I am importing this file to my index, and including an intentional error in this file to test it:

const Sentry = require('./logging/sentry.js')


try {
    doSomeFunction();
} catch(error) {
    Sentry.captureException(error);
}

What's wrong here? Am I using Sentry wrong? I've not been able to find any info regarding this. I was able to get it to work on my machine (of course haha) but when I deployed it to my Docker container, it did not work, which makes me believe this might be part of the issue.

Thank you!

UPDATE:

Tried rewriting this with no luck, I'm truly unsure what is wrong here, I cannot get it to work even though I am following the documentation. Some help would be really appreciated.

UPDATE2:

I am now confident this issue is due to Docker, possibly blocking port 443. I have done sudo ufw allow 443 with success, but the issue is still intact.

UPDATE3:

Based on some readings I believe IPTables is having this issue (maybe even cloudflare?)

Here is my IPTables:

Chain PREROUTING (policy ACCEPT)
target     prot opt source               destination         
DOCKER     all  --  anywhere             anywhere             ADDRTYPE match dst-type LOCAL
DNAT       tcp  --  anywhere             anywhere             tcp dpt:https to:172.17.0.3:8443

Chain INPUT (policy ACCEPT)
target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination         
DOCKER     all  --  anywhere            !localhost/8          ADDRTYPE match dst-type LOCAL

Chain POSTROUTING (policy ACCEPT)
target     prot opt source               destination         
MASQUERADE  all  --  172.17.0.0/16        anywhere            
MASQUERADE  all  --  172.18.0.0/16        anywhere            
MASQUERADE  tcp  --  172.18.0.6           172.18.0.6           tcp dpt:3000
MASQUERADE  tcp  --  172.18.0.7           172.18.0.7           tcp dpt:https
MASQUERADE  tcp  --  172.18.0.7           172.18.0.7           tcp dpt:http

Chain DOCKER (2 references)
target     prot opt source               destination         
RETURN     all  --  anywhere             anywhere            
RETURN     all  --  anywhere             anywhere            
DNAT       tcp  --  anywhere             anywhere             tcp dpt:3000 to:172.18.0.6:3000
DNAT       tcp  --  anywhere             anywhere             tcp dpt:https to:172.18.0.7:443
DNAT       tcp  --  anywhere             anywhere             tcp dpt:http to:172.18.0.7:80

I wonder if this is relevant!


Solution

    1. Is DSN An array, or a String? It should be a String according to the Sentry docs.

    2. An error which mentions 0.0.0.0 is frequently DNS related. Have you checked the DNS configuration for your docker? Is there a hosts file? A possible cause could be something intercepting the DNS requests and returning 0.0.0.0.