sentry-javascript-bundler-plugins
sentry-javascript-bundler-plugins copied to clipboard
Sourcemaps repeatedly uploading with esbuild plugin
Environment
"@sentry/aws-serverless": "^8.26.0" "@sentry/esbuild-plugin": "^2.22.2" "serverless": "^3.26.0" "serverless-esbuild": "^1.52.1"
Description
Sourcemaps should be uploaded for aws lambda functions when packaging (sls package
). I've tried two different configurations:
- Loading the sentry esbuild-plugin as a serverless-esbuild plugin as suggested here. This results in good stack traces but the sourcemaps are uploaded repeatedly when run in a Github Action. It finds something like 4 files then uploads then 8 files then uploads and repeats until it finds all the files. How often it's uploaded and the number of files found is different every time.
serverless.yml
package:
individually: true
custom:
esbuild:
bundle: true
minify: false
sourcemap: true
platform: 'node'
outputBuildFolder: '.build'
keepOutputDirectory: true
skipRebuild: true
logLevel: debug
plugins: './esbuild.plugins.js'
esbuild.plugin.js
const { sentryEsbuildPlugin } = require('@sentry/esbuild-plugin');
module.exports = (serverless) => {
return [
sentryEsbuildPlugin({
org: my_org,
project: my_project,
authToken:
process.env.SOURCEMAPS === 'true'
? serverless.configurationInput.provider.environment.SENTRY_AUTH_TOKEN
: undefined,
sourcemaps: {
assets: ['./.esbuild/.build/**/*'],
filesToDeleteAfterUpload: ['./.esbuild/.build/**/*.js.map'],
},
telemetry: false,
debug: true,
}),
]
}
- Loading the sentry plugin within the esbuild.config.js as per the documentation. This uploads the sourcemaps only once however the sourcemap debug IDs are injected into the output esbuild folder but not the .serverless folder which gets deployed so we get no stack trace in Sentry.
serverless.yml
package:
individually: true
custom:
esbuild:
config: './esbuild.config.js'
esbuild.config.js
const { sentryEsbuildPlugin } = require("@sentry/esbuild-plugin");
const esbuild = require("esbuild");
const glob = require("glob");
module.exports = async (serverless) => {
const sources = glob.sync('./src/**/index.ts');
await esbuild.build({
entryPoints: sources,
bundle: true,
minify: false,
sourcemap: true,
platform: 'node',
outdir: '.dist-esbuild',
logLevel: 'debug',
plugins: [
sentryEsbuildPlugin({
org: my_org,
project: my_project,
authToken: process.env.SOURCEMAPS === 'true'
? serverless.configurationInput.provider.environment.SENTRY_AUTH_TOKEN
: undefined,
sourcemaps: {
assets: './.dist-esbuild/**/*',
filesToDeleteAfterUpload: ['./.dist-esbuild/**/*.js.map'],
},
telemetry: false,
debug: true,
}),
]
})
}