@sentry/bundler-plugin-core 2.21.0 → 2.21.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -13619,7 +13619,7 @@ function createSentryInstance(options, shouldSendTelemetry, bundler) {
13619
13619
  dsn: "https://4c2bae7d9fbc413e8f7385f55c515d51@o1.ingest.sentry.io/6690737",
13620
13620
  tracesSampleRate: 1,
13621
13621
  sampleRate: 1,
13622
- release: "2.21.0",
13622
+ release: "2.21.1",
13623
13623
  integrations: [],
13624
13624
  tracePropagationTargets: ["sentry.io/api"],
13625
13625
  stackParser: defaultStackParser,
@@ -13823,23 +13823,27 @@ function createDebugIdUploadFunction(_ref) {
13823
13823
  sentryClient = _ref.sentryClient,
13824
13824
  sentryCliOptions = _ref.sentryCliOptions,
13825
13825
  rewriteSourcesHook = _ref.rewriteSourcesHook,
13826
- freeDependencyOnSourcemapFiles = _ref.freeDependencyOnSourcemapFiles;
13826
+ createDependencyOnSourcemapFiles = _ref.createDependencyOnSourcemapFiles;
13827
+ var freeGlobalDependencyOnSourcemapFiles = createDependencyOnSourcemapFiles();
13827
13828
  return /*#__PURE__*/function () {
13828
13829
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(buildArtifactPaths) {
13829
- var artifactBundleUploadTransaction, folderToCleanUp, mkdtempSpan, tmpUploadFolder, globAssets, globSpan, globResult, debugIdChunkFilePaths, prepareSpan, preparationTasks, workers, worker, workerIndex, files, stats, uploadSize, uploadSpan, cliInstance, cleanupSpan;
13830
+ var artifactBundleUploadTransaction, folderToCleanUp, freeUploadDependencyOnSourcemapFiles, mkdtempSpan, tmpUploadFolder, globAssets, globSpan, globResult, debugIdChunkFilePaths, prepareSpan, preparationTasks, workers, worker, workerIndex, files, stats, uploadSize, uploadSpan, cliInstance, cleanupSpan;
13830
13831
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
13831
13832
  while (1) switch (_context3.prev = _context3.next) {
13832
13833
  case 0:
13833
13834
  artifactBundleUploadTransaction = sentryHub.startTransaction({
13834
13835
  name: "debug-id-sourcemap-upload"
13835
13836
  });
13836
- _context3.prev = 1;
13837
+ // It is possible that this writeBundle hook (which calls this function) is called multiple times in one build (for example when reusing the plugin, or when using build tooling like `@vitejs/plugin-legacy`)
13838
+ // Therefore we need to actually register the execution of this hook as dependency on the sourcemap files.
13839
+ freeUploadDependencyOnSourcemapFiles = createDependencyOnSourcemapFiles();
13840
+ _context3.prev = 2;
13837
13841
  mkdtempSpan = artifactBundleUploadTransaction.startChild({
13838
13842
  description: "mkdtemp"
13839
13843
  });
13840
- _context3.next = 5;
13844
+ _context3.next = 6;
13841
13845
  return fs__default.promises.mkdtemp(path__default.join(os__default.tmpdir(), "sentry-bundler-plugin-upload-"));
13842
- case 5:
13846
+ case 6:
13843
13847
  tmpUploadFolder = _context3.sent;
13844
13848
  mkdtempSpan.finish();
13845
13849
  folderToCleanUp = tmpUploadFolder;
@@ -13852,13 +13856,13 @@ function createDebugIdUploadFunction(_ref) {
13852
13856
  globSpan = artifactBundleUploadTransaction.startChild({
13853
13857
  description: "glob"
13854
13858
  });
13855
- _context3.next = 12;
13859
+ _context3.next = 13;
13856
13860
  return glob(globAssets, {
13857
13861
  absolute: true,
13858
13862
  nodir: true,
13859
13863
  ignore: ignore
13860
13864
  });
13861
- case 12:
13865
+ case 13:
13862
13866
  globResult = _context3.sent;
13863
13867
  globSpan.finish();
13864
13868
  debugIdChunkFilePaths = globResult.filter(function (debugIdChunkFilePath) {
@@ -13867,21 +13871,21 @@ function createDebugIdUploadFunction(_ref) {
13867
13871
  // Ensure order within the files so that {debug-id}-{chunkIndex} coupling is consistent
13868
13872
  debugIdChunkFilePaths.sort();
13869
13873
  if (!(Array.isArray(assets) && assets.length === 0)) {
13870
- _context3.next = 20;
13874
+ _context3.next = 21;
13871
13875
  break;
13872
13876
  }
13873
13877
  logger.debug("Empty `sourcemaps.assets` option provided. Will not upload sourcemaps with debug ID.");
13874
- _context3.next = 47;
13878
+ _context3.next = 48;
13875
13879
  break;
13876
- case 20:
13880
+ case 21:
13877
13881
  if (!(debugIdChunkFilePaths.length === 0)) {
13878
- _context3.next = 24;
13882
+ _context3.next = 25;
13879
13883
  break;
13880
13884
  }
13881
13885
  logger.warn("Didn't find any matching sources for debug ID upload. Please check the `sourcemaps.assets` option.");
13882
- _context3.next = 47;
13886
+ _context3.next = 48;
13883
13887
  break;
13884
- case 24:
13888
+ case 25:
13885
13889
  prepareSpan = artifactBundleUploadTransaction.startChild({
13886
13890
  description: "prepare-bundles"
13887
13891
  }); // Preparing the bundles can be a lot of work and doing it all at once has the potential of nuking the heap so
@@ -13934,20 +13938,20 @@ function createDebugIdUploadFunction(_ref) {
13934
13938
  for (workerIndex = 0; workerIndex < 16; workerIndex++) {
13935
13939
  workers.push(worker());
13936
13940
  }
13937
- _context3.next = 31;
13941
+ _context3.next = 32;
13938
13942
  return Promise.all(workers);
13939
- case 31:
13943
+ case 32:
13940
13944
  prepareSpan.finish();
13941
- _context3.next = 34;
13945
+ _context3.next = 35;
13942
13946
  return fs__default.promises.readdir(tmpUploadFolder);
13943
- case 34:
13947
+ case 35:
13944
13948
  files = _context3.sent;
13945
13949
  stats = files.map(function (file) {
13946
13950
  return fs__default.promises.stat(path__default.join(tmpUploadFolder, file));
13947
13951
  });
13948
- _context3.next = 38;
13952
+ _context3.next = 39;
13949
13953
  return Promise.all(stats);
13950
- case 38:
13954
+ case 39:
13951
13955
  uploadSize = _context3.sent.reduce(function (accumulator, _ref5) {
13952
13956
  var size = _ref5.size;
13953
13957
  return accumulator + size;
@@ -13964,7 +13968,7 @@ function createDebugIdUploadFunction(_ref) {
13964
13968
  baggage: dynamicSamplingContextToSentryBaggageHeader(artifactBundleUploadTransaction.getDynamicSamplingContext())
13965
13969
  }, sentryCliOptions.headers)
13966
13970
  }));
13967
- _context3.next = 45;
13971
+ _context3.next = 46;
13968
13972
  return cliInstance.releases.uploadSourceMaps(releaseName !== null && releaseName !== void 0 ? releaseName : "undefined",
13969
13973
  // unfortunetly this needs a value for now but it will not matter since debug IDs overpower releases anyhow
13970
13974
  {
@@ -13975,22 +13979,22 @@ function createDebugIdUploadFunction(_ref) {
13975
13979
  }],
13976
13980
  useArtifactBundle: true
13977
13981
  });
13978
- case 45:
13982
+ case 46:
13979
13983
  uploadSpan.finish();
13980
13984
  logger.info("Successfully uploaded source maps to Sentry");
13981
- case 47:
13982
- _context3.next = 53;
13985
+ case 48:
13986
+ _context3.next = 54;
13983
13987
  break;
13984
- case 49:
13985
- _context3.prev = 49;
13986
- _context3.t0 = _context3["catch"](1);
13988
+ case 50:
13989
+ _context3.prev = 50;
13990
+ _context3.t0 = _context3["catch"](2);
13987
13991
  sentryHub.withScope(function (scope) {
13988
13992
  scope.setSpan(artifactBundleUploadTransaction);
13989
13993
  sentryHub.captureException('Error in "debugIdUploadPlugin" writeBundle hook');
13990
13994
  });
13991
13995
  handleRecoverableError(_context3.t0);
13992
- case 53:
13993
- _context3.prev = 53;
13996
+ case 54:
13997
+ _context3.prev = 54;
13994
13998
  if (folderToCleanUp) {
13995
13999
  cleanupSpan = artifactBundleUploadTransaction.startChild({
13996
14000
  description: "cleanup"
@@ -14002,16 +14006,17 @@ function createDebugIdUploadFunction(_ref) {
14002
14006
  cleanupSpan.finish();
14003
14007
  }
14004
14008
  artifactBundleUploadTransaction.finish();
14005
- freeDependencyOnSourcemapFiles();
14006
- _context3.next = 59;
14009
+ freeGlobalDependencyOnSourcemapFiles();
14010
+ freeUploadDependencyOnSourcemapFiles();
14011
+ _context3.next = 61;
14007
14012
  return safeFlushTelemetry(sentryClient);
14008
- case 59:
14009
- return _context3.finish(53);
14010
- case 60:
14013
+ case 61:
14014
+ return _context3.finish(54);
14015
+ case 62:
14011
14016
  case "end":
14012
14017
  return _context3.stop();
14013
14018
  }
14014
- }, _callee3, null, [[1, 49, 53, 60]]);
14019
+ }, _callee3, null, [[2, 50, 54, 62]]);
14015
14020
  }));
14016
14021
  return function (_x) {
14017
14022
  return _ref2.apply(this, arguments);
@@ -14258,26 +14263,30 @@ function releaseManagementPlugin(_ref) {
14258
14263
  sentryHub = _ref.sentryHub,
14259
14264
  sentryClient = _ref.sentryClient,
14260
14265
  sentryCliOptions = _ref.sentryCliOptions,
14261
- freeDependencyOnSourcemapFiles = _ref.freeDependencyOnSourcemapFiles;
14266
+ createDependencyOnSourcemapFiles = _ref.createDependencyOnSourcemapFiles;
14267
+ var freeGlobalDependencyOnSourcemapFiles = createDependencyOnSourcemapFiles();
14262
14268
  return {
14263
14269
  name: "sentry-debug-id-upload-plugin",
14264
14270
  writeBundle: function writeBundle() {
14265
14271
  return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
14266
- var cliInstance, normalizedInclude;
14272
+ var freeWriteBundleInvocationDependencyOnSourcemapFiles, cliInstance, normalizedInclude;
14267
14273
  return _regeneratorRuntime().wrap(function _callee$(_context) {
14268
14274
  while (1) switch (_context.prev = _context.next) {
14269
14275
  case 0:
14270
- _context.prev = 0;
14276
+ // It is possible that this writeBundle hook is called multiple times in one build (for example when reusing the plugin, or when using build tooling like `@vitejs/plugin-legacy`)
14277
+ // Therefore we need to actually register the execution of this hook as dependency on the sourcemap files.
14278
+ freeWriteBundleInvocationDependencyOnSourcemapFiles = createDependencyOnSourcemapFiles();
14279
+ _context.prev = 1;
14271
14280
  cliInstance = new SentryCli(null, sentryCliOptions);
14272
14281
  if (!shouldCreateRelease) {
14273
- _context.next = 5;
14282
+ _context.next = 6;
14274
14283
  break;
14275
14284
  }
14276
- _context.next = 5;
14285
+ _context.next = 6;
14277
14286
  return cliInstance.releases["new"](releaseName);
14278
- case 5:
14287
+ case 6:
14279
14288
  if (!include) {
14280
- _context.next = 9;
14289
+ _context.next = 10;
14281
14290
  break;
14282
14291
  }
14283
14292
  normalizedInclude = arrayify$1(include).map(function (includeItem) {
@@ -14294,52 +14303,53 @@ function releaseManagementPlugin(_ref) {
14294
14303
  ignore: includeEntry.ignore ? arrayify$1(includeEntry.ignore) : undefined
14295
14304
  });
14296
14305
  });
14297
- _context.next = 9;
14306
+ _context.next = 10;
14298
14307
  return cliInstance.releases.uploadSourceMaps(releaseName, {
14299
14308
  include: normalizedInclude,
14300
14309
  dist: dist
14301
14310
  });
14302
- case 9:
14311
+ case 10:
14303
14312
  if (!setCommitsOption) {
14304
- _context.next = 12;
14313
+ _context.next = 13;
14305
14314
  break;
14306
14315
  }
14307
- _context.next = 12;
14316
+ _context.next = 13;
14308
14317
  return cliInstance.releases.setCommits(releaseName, setCommitsOption);
14309
- case 12:
14318
+ case 13:
14310
14319
  if (!shouldFinalizeRelease) {
14311
- _context.next = 15;
14320
+ _context.next = 16;
14312
14321
  break;
14313
14322
  }
14314
- _context.next = 15;
14323
+ _context.next = 16;
14315
14324
  return cliInstance.releases.finalize(releaseName);
14316
- case 15:
14325
+ case 16:
14317
14326
  if (!deployOptions) {
14318
- _context.next = 18;
14327
+ _context.next = 19;
14319
14328
  break;
14320
14329
  }
14321
- _context.next = 18;
14330
+ _context.next = 19;
14322
14331
  return cliInstance.releases.newDeploy(releaseName, deployOptions);
14323
- case 18:
14324
- _context.next = 26;
14332
+ case 19:
14333
+ _context.next = 27;
14325
14334
  break;
14326
- case 20:
14327
- _context.prev = 20;
14328
- _context.t0 = _context["catch"](0);
14335
+ case 21:
14336
+ _context.prev = 21;
14337
+ _context.t0 = _context["catch"](1);
14329
14338
  sentryHub.captureException('Error in "releaseManagementPlugin" writeBundle hook');
14330
- _context.next = 25;
14339
+ _context.next = 26;
14331
14340
  return safeFlushTelemetry(sentryClient);
14332
- case 25:
14333
- handleRecoverableError(_context.t0);
14334
14341
  case 26:
14335
- _context.prev = 26;
14336
- freeDependencyOnSourcemapFiles();
14337
- return _context.finish(26);
14338
- case 29:
14342
+ handleRecoverableError(_context.t0);
14343
+ case 27:
14344
+ _context.prev = 27;
14345
+ freeGlobalDependencyOnSourcemapFiles();
14346
+ freeWriteBundleInvocationDependencyOnSourcemapFiles();
14347
+ return _context.finish(27);
14348
+ case 31:
14339
14349
  case "end":
14340
14350
  return _context.stop();
14341
14351
  }
14342
- }, _callee, null, [[0, 20, 26, 29]]);
14352
+ }, _callee, null, [[1, 21, 27, 31]]);
14343
14353
  }))();
14344
14354
  }
14345
14355
  };
@@ -14430,73 +14440,62 @@ function fileDeletionPlugin(_ref) {
14430
14440
  sentryHub = _ref.sentryHub,
14431
14441
  sentryClient = _ref.sentryClient,
14432
14442
  filesToDeleteAfterUpload = _ref.filesToDeleteAfterUpload,
14433
- dependenciesAreFreedPromise = _ref.dependenciesAreFreedPromise,
14443
+ waitUntilSourcemapFileDependenciesAreFreed = _ref.waitUntilSourcemapFileDependenciesAreFreed,
14434
14444
  logger = _ref.logger;
14435
- var writeBundle = /*#__PURE__*/function () {
14436
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
14437
- var filePathsToDelete;
14438
- return _regeneratorRuntime().wrap(function _callee$(_context) {
14439
- while (1) switch (_context.prev = _context.next) {
14440
- case 0:
14441
- _context.prev = 0;
14442
- if (!(filesToDeleteAfterUpload !== undefined)) {
14443
- _context.next = 11;
14444
- break;
14445
- }
14446
- _context.next = 4;
14447
- return glob(filesToDeleteAfterUpload, {
14448
- absolute: true,
14449
- nodir: true
14450
- });
14451
- case 4:
14452
- filePathsToDelete = _context.sent;
14453
- logger.debug("Waiting for dependencies on generated files to be freed before deleting...");
14454
- _context.next = 8;
14455
- return dependenciesAreFreedPromise;
14456
- case 8:
14457
- filePathsToDelete.forEach(function (filePathToDelete) {
14458
- logger.debug("Deleting asset after upload: ".concat(filePathToDelete));
14459
- });
14460
- _context.next = 11;
14461
- return Promise.all(filePathsToDelete.map(function (filePathToDelete) {
14462
- return fs__default.promises.rm(filePathToDelete, {
14463
- force: true
14464
- })["catch"](function (e) {
14465
- // This is allowed to fail - we just don't do anything
14466
- logger.debug("An error occurred while attempting to delete asset: ".concat(filePathToDelete), e);
14467
- });
14468
- }));
14469
- case 11:
14470
- _context.next = 19;
14471
- break;
14472
- case 13:
14473
- _context.prev = 13;
14474
- _context.t0 = _context["catch"](0);
14475
- sentryHub.captureException('Error in "sentry-file-deletion-plugin" buildEnd hook');
14476
- _context.next = 18;
14477
- return safeFlushTelemetry(sentryClient);
14478
- case 18:
14479
- handleRecoverableError(_context.t0);
14480
- case 19:
14481
- case "end":
14482
- return _context.stop();
14483
- }
14484
- }, _callee, null, [[0, 13]]);
14485
- }));
14486
- return function writeBundle() {
14487
- return _ref2.apply(this, arguments);
14488
- };
14489
- }();
14490
14445
  return {
14491
14446
  name: "sentry-file-deletion-plugin",
14492
- vite: {
14493
- writeBundle: {
14494
- sequential: true,
14495
- order: "post",
14496
- handler: writeBundle
14497
- }
14498
- },
14499
- writeBundle: writeBundle
14447
+ writeBundle: function writeBundle() {
14448
+ return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
14449
+ var filePathsToDelete;
14450
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
14451
+ while (1) switch (_context.prev = _context.next) {
14452
+ case 0:
14453
+ _context.prev = 0;
14454
+ if (!(filesToDeleteAfterUpload !== undefined)) {
14455
+ _context.next = 11;
14456
+ break;
14457
+ }
14458
+ _context.next = 4;
14459
+ return glob(filesToDeleteAfterUpload, {
14460
+ absolute: true,
14461
+ nodir: true
14462
+ });
14463
+ case 4:
14464
+ filePathsToDelete = _context.sent;
14465
+ logger.debug("Waiting for dependencies on generated files to be freed before deleting...");
14466
+ _context.next = 8;
14467
+ return waitUntilSourcemapFileDependenciesAreFreed();
14468
+ case 8:
14469
+ filePathsToDelete.forEach(function (filePathToDelete) {
14470
+ logger.debug("Deleting asset after upload: ".concat(filePathToDelete));
14471
+ });
14472
+ _context.next = 11;
14473
+ return Promise.all(filePathsToDelete.map(function (filePathToDelete) {
14474
+ return fs__default.promises.rm(filePathToDelete, {
14475
+ force: true
14476
+ })["catch"](function (e) {
14477
+ // This is allowed to fail - we just don't do anything
14478
+ logger.debug("An error occurred while attempting to delete asset: ".concat(filePathToDelete), e);
14479
+ });
14480
+ }));
14481
+ case 11:
14482
+ _context.next = 19;
14483
+ break;
14484
+ case 13:
14485
+ _context.prev = 13;
14486
+ _context.t0 = _context["catch"](0);
14487
+ sentryHub.captureException('Error in "sentry-file-deletion-plugin" buildEnd hook');
14488
+ _context.next = 18;
14489
+ return safeFlushTelemetry(sentryClient);
14490
+ case 18:
14491
+ handleRecoverableError(_context.t0);
14492
+ case 19:
14493
+ case "end":
14494
+ return _context.stop();
14495
+ }
14496
+ }, _callee, null, [[0, 13]]);
14497
+ }))();
14498
+ }
14500
14499
  };
14501
14500
  }
14502
14501
 
@@ -14584,7 +14583,7 @@ function sentryUnpluginFactory(_ref) {
14584
14583
  });
14585
14584
 
14586
14585
  // Set the User-Agent that Sentry CLI will use when interacting with Sentry
14587
- process.env["SENTRY_PIPELINE"] = "".concat(unpluginMetaContext.framework, "-plugin/", "2.21.0");
14586
+ process.env["SENTRY_PIPELINE"] = "".concat(unpluginMetaContext.framework, "-plugin/", "2.21.1");
14588
14587
  function handleRecoverableError(unknownError) {
14589
14588
  sentrySession.status = "abnormal";
14590
14589
  try {
@@ -14645,6 +14644,9 @@ function sentryUnpluginFactory(_ref) {
14645
14644
 
14646
14645
  /**
14647
14646
  * Returns a Promise that resolves when all the currently active dependencies are freed again.
14647
+ *
14648
+ * It is very important that this function is called as late as possible before wanting to await the Promise to give
14649
+ * the dependency producers as much time as possible to register themselves.
14648
14650
  */
14649
14651
  function waitUntilSourcemapFileDependenciesAreFreed() {
14650
14652
  return new Promise(function (resolve) {
@@ -14752,7 +14754,7 @@ function sentryUnpluginFactory(_ref) {
14752
14754
  vcsRemote: options.release.vcsRemote,
14753
14755
  headers: options.headers
14754
14756
  },
14755
- freeDependencyOnSourcemapFiles: createDependencyOnSourcemapFiles()
14757
+ createDependencyOnSourcemapFiles: createDependencyOnSourcemapFiles
14756
14758
  }));
14757
14759
  }
14758
14760
  plugins.push(debugIdInjectionPlugin(logger));
@@ -14767,7 +14769,7 @@ function sentryUnpluginFactory(_ref) {
14767
14769
  plugins.push(debugIdUploadPlugin(createDebugIdUploadFunction({
14768
14770
  assets: (_options$sourcemaps2 = options.sourcemaps) === null || _options$sourcemaps2 === void 0 ? void 0 : _options$sourcemaps2.assets,
14769
14771
  ignore: (_options$sourcemaps3 = options.sourcemaps) === null || _options$sourcemaps3 === void 0 ? void 0 : _options$sourcemaps3.ignore,
14770
- freeDependencyOnSourcemapFiles: createDependencyOnSourcemapFiles(),
14772
+ createDependencyOnSourcemapFiles: createDependencyOnSourcemapFiles,
14771
14773
  dist: options.release.dist,
14772
14774
  releaseName: options.release.name,
14773
14775
  logger: logger,
@@ -14796,9 +14798,7 @@ function sentryUnpluginFactory(_ref) {
14796
14798
  }
14797
14799
  }
14798
14800
  plugins.push(fileDeletionPlugin({
14799
- // It is very important that this is only called after all other dependencies have been created with `createDependencyOnSourcemapFiles`.
14800
- // Ideally, we always register this plugin last.
14801
- dependenciesAreFreedPromise: waitUntilSourcemapFileDependenciesAreFreed(),
14801
+ waitUntilSourcemapFileDependenciesAreFreed: waitUntilSourcemapFileDependenciesAreFreed,
14802
14802
  filesToDeleteAfterUpload: (_options$sourcemaps$f = (_options$sourcemaps5 = options.sourcemaps) === null || _options$sourcemaps5 === void 0 ? void 0 : _options$sourcemaps5.filesToDeleteAfterUpload) !== null && _options$sourcemaps$f !== void 0 ? _options$sourcemaps$f : (_options$sourcemaps6 = options.sourcemaps) === null || _options$sourcemaps6 === void 0 ? void 0 : _options$sourcemaps6.deleteFilesAfterUpload,
14803
14803
  logger: logger,
14804
14804
  handleRecoverableError: handleRecoverableError,