sentry-javascript: Source code was not found for index.js
Package + Version
-
@sentry/browser -
@sentry/node -
raven-js -
raven-node(raven for node) - other:
Version:
4.4.1
Description
The following event capturing code will produce an error in Sentry while parsing the event: Source code was not found for /.../index.js
const Sentry = require('@sentry/node');
Sentry.init({ dsn: 'https://5d29[...]58f@sentry.io/13[...]6' });
(async () => {
const sentryEvent = await Sentry.Parsers.parseError(new Error('Test'));
Sentry.captureEvent(sentryEvent);
})();
Here is how the event looks like in Sentry:

About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 12
- Comments: 28 (11 by maintainers)
@guischdi the reason why you get this error is that local file paths are not reachable to remote servers. Sentry is trying to fetch and resolve
/something/local/src/app.jsand read the source-code from it to provide better error mappings (it works in the same way with sourcemap files).To upload your files, you can use our CLI https://docs.sentry.io/cli/ or Webpack plugin https://github.com/getsentry/sentry-webpack-plugin
Here are some old docs on source maps, but the concept is the same for new SDK https://docs.sentry.io/clients/node/sourcemaps/ (it all applies in the same way to your current issue).
There’s also an existing integration you can use to rewrite paths in every frame https://github.com/getsentry/sentry-javascript/blob/master/packages/core/src/integrations/pluggable/rewriteframes.ts
So for example:
Will change
/something/local/src/app.jstoapp:///app.js(app:///is our internal prefix), so when you uploadapp.jsto your sentry release artifacts, it will be read correctly without a need to fetch external files.Basically what you need to do is:
releaseininitcallHope it clears some things for you. Feel free to ask anything if you need more help.
Ok, so this looks like a UX bug to me. In my opinion it should (at least for Node.js projects) be only a warning and it must not say
Source code was not foundbut something likeSource maps were not found. This would have prevented an issue with a history of more than a year 😉 If you want you can reopen this issue as a report for whoever works on the frontend/display part, or just leave it closed and report this misunderstanding to them. Thanks a lot for finally clarifying this!@guischdi sorry for such a late response. I lost a track a bit. Can you refresh my memory what’s going on here and provide some sample events?
Can you post a direct link to the event?
(you also missed some paths in the stacktrace screenshot you masked earlier 😅)
Any particular reason why you don’t use
Sentry.captureExceptiondirectly, but rather want to create your own event?@guischdi we are investigating why it’s behaving like this (2 consecutive frames with the same url triggers this). In the meantime, you can turn off “Enable JavaScript Source Fetching” in your project’s settings, eg. https://sentry.io/settings/kamil-ogorek/projects/testing-project/ It’s node app, so there’s no point in doing that.
I’m running Sentry self-hosted and using
@sentry/node 5.4.3Heres my code:
I’m also getting this error:
And here is the stack:
Odd, that works for me just fine. Anyways, we’ll try to investigate why that happens, although I cannot promise when it happens, as it’s not major issue preventing anything from working. Will keep you posted!
@guischdi just to confirm, this is raw node js file right? no webpack, no compilation, no source maps. Just one
index.jsfile with 2 different calls on different lines? Can you provide the content of this file if possible?@guischdi can you past full link to both events? Not shareable ones? I can access them through admin permissions.
Also, I’ll be out of office for the next 3 weeks, so I’ll try to get back to this one when I’ll come back.