@sentry/bundler-plugin-core 3.2.0 → 3.2.2

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.
package/dist/cjs/index.js CHANGED
@@ -8111,7 +8111,7 @@ function createSentryInstance(options, shouldSendTelemetry, bundler) {
8111
8111
  dsn: "https://4c2bae7d9fbc413e8f7385f55c515d51@o1.ingest.sentry.io/6690737",
8112
8112
  tracesSampleRate: 1,
8113
8113
  sampleRate: 1,
8114
- release: "3.2.0",
8114
+ release: "3.2.2",
8115
8115
  integrations: [],
8116
8116
  tracePropagationTargets: ["sentry.io/api"],
8117
8117
  stackParser: stackParser,
@@ -8479,7 +8479,7 @@ function createDebugIdUploadFunction(_ref) {
8479
8479
  }));
8480
8480
  _context5.next = 3;
8481
8481
  return cliInstance.releases.uploadSourceMaps(releaseName !== null && releaseName !== void 0 ? releaseName : "undefined",
8482
- // unfortunetly this needs a value for now but it will not matter since debug IDs overpower releases anyhow
8482
+ // unfortunately this needs a value for now but it will not matter since debug IDs overpower releases anyhow
8483
8483
  {
8484
8484
  include: [{
8485
8485
  paths: [tmpUploadFolder],
@@ -8517,7 +8517,7 @@ function createDebugIdUploadFunction(_ref) {
8517
8517
  _context8.prev = 25;
8518
8518
  _context8.t0 = _context8["catch"](1);
8519
8519
  sentryScope.captureException('Error in "debugIdUploadPlugin" writeBundle hook');
8520
- handleRecoverableError(_context8.t0);
8520
+ handleRecoverableError(_context8.t0, false);
8521
8521
  case 29:
8522
8522
  _context8.prev = 29;
8523
8523
  if (folderToCleanUp) {
@@ -8888,7 +8888,7 @@ function releaseManagementPlugin(_ref) {
8888
8888
  _context.next = 26;
8889
8889
  return safeFlushTelemetry(sentryClient);
8890
8890
  case 26:
8891
- handleRecoverableError(_context.t0);
8891
+ handleRecoverableError(_context.t0, false);
8892
8892
  case 27:
8893
8893
  _context.prev = 27;
8894
8894
  freeGlobalDependencyOnSourcemapFiles();
@@ -9045,7 +9045,9 @@ function fileDeletionPlugin(_ref) {
9045
9045
  _context.next = 21;
9046
9046
  return safeFlushTelemetry(sentryClient);
9047
9047
  case 21:
9048
- handleRecoverableError(_context.t0);
9048
+ // We throw by default if we get here b/c not being able to delete
9049
+ // source maps could leak them to production
9050
+ handleRecoverableError(_context.t0, true);
9049
9051
  case 22:
9050
9052
  case "end":
9051
9053
  return _context.stop();
@@ -9156,8 +9158,18 @@ function sentryUnpluginFactory(_ref) {
9156
9158
  });
9157
9159
 
9158
9160
  // Set the User-Agent that Sentry CLI will use when interacting with Sentry
9159
- process.env["SENTRY_PIPELINE"] = "".concat(unpluginMetaContext.framework, "-plugin/", "3.2.0");
9160
- function handleRecoverableError(unknownError) {
9161
+ process.env["SENTRY_PIPELINE"] = "".concat(unpluginMetaContext.framework, "-plugin/", "3.2.2");
9162
+
9163
+ /**
9164
+ * Handles errors caught and emitted in various areas of the plugin.
9165
+ *
9166
+ * Also sets the sentry session status according to the error handling.
9167
+ *
9168
+ * If users specify their custom `errorHandler` we'll leave the decision to throw
9169
+ * or continue up to them. By default, @param throwByDefault controls if the plugin
9170
+ * should throw an error (which causes a build fail in most bundlers) or continue.
9171
+ */
9172
+ function handleRecoverableError(unknownError, throwByDefault) {
9161
9173
  sentrySession.status = "abnormal";
9162
9174
  try {
9163
9175
  if (options.errorHandler) {
@@ -9172,15 +9184,21 @@ function sentryUnpluginFactory(_ref) {
9172
9184
  throw e;
9173
9185
  }
9174
9186
  } else {
9187
+ // setting the session to "crashed" b/c from a plugin perspective this run failed.
9188
+ // However, we're intentionally not rethrowing the error to avoid breaking the user build.
9175
9189
  sentrySession.status = "crashed";
9176
- throw unknownError;
9190
+ if (throwByDefault) {
9191
+ throw unknownError;
9192
+ }
9193
+ logger.error("An error occurred. Couldn't finish all operations:", unknownError);
9177
9194
  }
9178
9195
  } finally {
9179
9196
  endSession();
9180
9197
  }
9181
9198
  }
9182
9199
  if (!validateOptions(options, logger)) {
9183
- handleRecoverableError(new Error("Options were not set correctly. See output above for more details."));
9200
+ // Throwing by default to avoid a misconfigured plugin going unnoticed.
9201
+ handleRecoverableError(new Error("Options were not set correctly. See output above for more details."), true);
9184
9202
  }
9185
9203
  if (process.cwd().match(/\\node_modules\\|\/node_modules\//)) {
9186
9204
  logger.warn("Running Sentry plugin from within a `node_modules` folder. Some features may not work.");
@@ -9295,16 +9313,21 @@ function sentryUnpluginFactory(_ref) {
9295
9313
  var _injectionCode2 = generateModuleMetadataInjectorCode(metadata);
9296
9314
  plugins.push(moduleMetadataInjectionPlugin(_injectionCode2));
9297
9315
  }
9316
+ // https://turbo.build/repo/docs/reference/system-environment-variables#environment-variables-in-tasks
9317
+ var isRunningInTurboRepo = Boolean(process.env["TURBO_HASH"]);
9318
+ var getTruboRepoEnvPassthroughWarning = function getTruboRepoEnvPassthroughWarning(envVarName) {
9319
+ return isRunningInTurboRepo ? "\nYou seem to be using Truborepo, did you forget to put ".concat(envVarName, " in `passThroughEnv`? https://turbo.build/repo/docs/reference/configuration#passthroughenv") : "";
9320
+ };
9298
9321
  if (!options.release.name) {
9299
9322
  logger.debug("No release name provided. Will not create release. Please set the `release.name` option to identify your release.");
9300
9323
  } else if (isDevMode) {
9301
9324
  logger.debug("Running in development mode. Will not create release.");
9302
9325
  } else if (!options.authToken) {
9303
- logger.warn("No auth token provided. Will not create release. Please set the `authToken` option. You can find information on how to generate a Sentry auth token here: https://docs.sentry.io/api/auth/");
9326
+ logger.warn("No auth token provided. Will not create release. Please set the `authToken` option. You can find information on how to generate a Sentry auth token here: https://docs.sentry.io/api/auth/" + getTruboRepoEnvPassthroughWarning("SENTRY_AUTH_TOKEN"));
9304
9327
  } else if (!options.org && !options.authToken.startsWith("sntrys_")) {
9305
- logger.warn("No organization slug provided. Will not create release. Please set the `org` option to your Sentry organization slug.");
9328
+ logger.warn("No organization slug provided. Will not create release. Please set the `org` option to your Sentry organization slug." + getTruboRepoEnvPassthroughWarning("SENTRY_ORG"));
9306
9329
  } else if (!options.project) {
9307
- logger.warn("No project provided. Will not create release. Please set the `project` option to your Sentry project slug.");
9330
+ logger.warn("No project provided. Will not create release. Please set the `project` option to your Sentry project slug." + getTruboRepoEnvPassthroughWarning("SENTRY_PROJECT"));
9308
9331
  } else {
9309
9332
  plugins.push(releaseManagementPlugin({
9310
9333
  logger: logger,
@@ -9338,11 +9361,11 @@ function sentryUnpluginFactory(_ref) {
9338
9361
  } else if (isDevMode) {
9339
9362
  logger.debug("Running in development mode. Will not upload sourcemaps.");
9340
9363
  } else if (!options.authToken) {
9341
- logger.warn("No auth token provided. Will not upload source maps. Please set the `authToken` option. You can find information on how to generate a Sentry auth token here: https://docs.sentry.io/api/auth/");
9364
+ logger.warn("No auth token provided. Will not upload source maps. Please set the `authToken` option. You can find information on how to generate a Sentry auth token here: https://docs.sentry.io/api/auth/" + getTruboRepoEnvPassthroughWarning("SENTRY_AUTH_TOKEN"));
9342
9365
  } else if (!options.org && !options.authToken.startsWith("sntrys_")) {
9343
- logger.warn("No org provided. Will not upload source maps. Please set the `org` option to your Sentry organization slug.");
9366
+ logger.warn("No org provided. Will not upload source maps. Please set the `org` option to your Sentry organization slug." + getTruboRepoEnvPassthroughWarning("SENTRY_ORG"));
9344
9367
  } else if (!options.project) {
9345
- logger.warn("No project provided. Will not upload source maps. Please set the `project` option to your Sentry project slug.");
9368
+ logger.warn("No project provided. Will not upload source maps. Please set the `project` option to your Sentry project slug." + getTruboRepoEnvPassthroughWarning("SENTRY_PROJECT"));
9346
9369
  } else {
9347
9370
  var _options$sourcemaps3, _options$sourcemaps4, _options$sourcemaps5;
9348
9371
  // This option is only strongly typed for the webpack plugin, where it is used. It has no effect on other plugins