-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Description
Is there an existing issue for this?
- I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues
- I have reviewed the documentation https://docs.sentry.io/
- I am using the latest SDK release https://github.com/getsentry/sentry-javascript/releases
How do you use Sentry?
Sentry Saas (sentry.io)
Which SDK are you using?
@sentry/node
SDK Version
9.18.0
Framework Version
No response
Link to Sentry event
Reproduction Example/SDK Setup
Sentry SDK Setup
import * as Sentry from '@sentry/node'
import { ENV } from './env.js'
Sentry.init({
dsn: ENV.SENTRY_DSN,
sendDefaultPii: true,
release: ENV.VERSION,
environment: ENV.ENVIRONMENT,
})
export { Sentry }tsconfig.json
{
"compilerOptions": {
// Strict mode
"strict": true,
"alwaysStrict": true,
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictBindCallApply": true,
"strictFunctionTypes": true,
"strictPropertyInitialization": true,
"useUnknownInCatchVariables": true,
"verbatimModuleSyntax": false,
// No unused code
"noUnusedLocals": true,
"allowUnreachableCode": false,
"noUnusedParameters": true,
"allowUnusedLabels": false,
// No implicit code
"noImplicitOverride": true,
"noImplicitReturns": true,
// Other Type Checks
"noUncheckedIndexedAccess": true,
"noPropertyAccessFromIndexSignature": true,
"noFallthroughCasesInSwitch": true,
"exactOptionalPropertyTypes": true,
"forceConsistentCasingInFileNames": true,
"skipLibCheck": true,
"resolveJsonModule": true,
// Compile
"target": "ES2020",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"removeComments": true,
"esModuleInterop": true,
"sourceMap": true,
"noEmitHelpers": true,
"importHelpers": true,
"lib": ["dom", "ES2020"],
"outDir": "./dist",
"rootDir": "./src",
"jsx": "react-jsx",
"paths": {
"@/*": ["./src/*"]
},
// Sentry Source Maps
// Set `sourceRoot` to "/" to strip the build path prefix
// from generated source code references.
// This improves issue grouping in Sentry.
"inlineSources": true,
"sourceRoot": "/"
},
"types": ["node", "jest"],
"include": ["src"],
"exclude": ["node_modules", "dist"]
}scripts/source-maps.sh
#!/usr/bin/env bash
set -euo pipefail
# Must run with doppler run --
BUILD_DIR=./dist
# Inject source maps
sentry-cli sourcemaps inject \
--org $SENTRY_ORG \
--project $SENTRY_PROJECT \
$BUILD_DIR
# Upload source maps
sentry-cli sourcemaps upload \
--org $SENTRY_ORG \
--project $SENTRY_PROJECT \
--release $VERSION \
--validate \
$BUILD_DIR
echo "Source maps injected and uploaded"scripts/build.sh
# Compile into dist/
echo "Compiling typescript..."
rm -rf ./dist
npx tsc
npx tsc-alias
npm run sentry:sourcemaps
# Build docker image
start_time=$(date +%s)
docker build . \
-t $IMAGE_URI \
--secret id=npmrc,src=$NPMRC_FILE_PATH \
--build-arg ENVIRONMENT=$ENVIRONMENT
end_time=$(date +%s)
duration=$((end_time - start_time))
echo "Docker build time: ${duration} seconds"Dockerfile
# ... truncating for readability
# Copy source code
COPY ./scripts ./scripts/
RUN chmod -R +x ./scripts
COPY dist/ dist/
# Start
CMD ["doppler", "run", "--", "pm2-runtime", "--kill-timeout", "30000", "dist/index.js"]
Additional Notes
- I referred to these docs
- We have a mono-repo that contains various microservices, this one is called
puppet-master - Using
sentry-cliversion2.45.0 - Our build process uses
tscto compilesrcintodistthentsc-aliasto replace path aliases like@/indist - I installed
tslibas a dev dependency and added "noEmitHelpers": true and -"importHelpers": true. totsconfig.jsonas per docs recommendations - I've confirmed that
- the compiled
.jsfiles have asourceMappingUrlanddebugIdcomment at the bottom of the file + a debug snippet (e.g.e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="a13cd456-25a6-5f96-9f75-6deb567d5102") - the source map is being uploaded, and the release matches the Sentry SDK setup. Note that there is no
debugIdproperty which these docs specify there should be
- the compiled
- Here is an example
.js.mapfile:
{
"version": 3,
"file": "auth.js",
"sources": [
"auth.ts"
],
"sourceRoot": "/",
"sourcesContent": [
"import * as msal from ..."
],
"names": [],
"mappings": ";;AAAA,OAAO,KAAK,IAAI,MAAM,...",
"debug_id": "fc4dfd90-2fe5-5a0e-bcc6-a22399856da8"
}- The uploaded source map contains artifacts like
~/auth.jsand~/auth.js.map
Steps to Reproduce
import { Sentry } from './sentry.js'
import { throwError } from './tmp.js' // throw new Error('test error')
try {
throwError()
} catch (err) {
Sentry.captureException(err)
}Expected Result
I would expect to see my code displaying within the event page
Actual Result
I do not see the code displaying within the event page
If I run sentry-cli sourcemaps explain $EVENT_ID --project $PROJECT"
then I see
⚠ DEPRECATION: `sourcemaps explain` has drifted from how sourcemap processing actually operates and its output may not be accurate. It will be removed in a future version of `sentry-cli`.
✔ Fetched data for event: 861ceb427ea74a9fb9d0e2ab8c69adeb
✔ Event has release name: 2.13.11
✔ Event has a valid exception present
✔ Event has a valid stacktrace present
✖ Event exception stacktrace selected frame (0) has incorrect abs_path (valid url is required). Found /tmp.ts
The event JSON is missing a debug_meta property and also includes:
"errors": [
{
"type": "js_no_source",
"symbolicator_type": "missing_source",
"url": "/processVideo.ts"
},
{
"type": "js_no_source",
"symbolicator_type": "missing_source",
"url": "/queue/queueReader.ts"
},
{
"type": "js_no_source",
"symbolicator_type": "missing_source",
"url": "/tmp.ts"
}
]You can view the full JSON event here
If I can provide any more information (including access to the project) then please let me know.
Metadata
Metadata
Assignees
Projects
Status
Waiting for: Product Owner
