@echoteam/signoz-react 1.2.14 → 1.2.16

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/index.esm.js CHANGED
@@ -16140,7 +16140,8 @@ function initializeSignOzTracing(config) {
16140
16140
  window.onerror = function (message, source, lineno, colno, error) {
16141
16141
  const errorMessage = String(message);
16142
16142
  const errorStack = (error === null || error === void 0 ? void 0 : error.stack) || '';
16143
- // Suppress SignOz timeout errors globally
16143
+ const errorSource = source || '';
16144
+ // Suppress SignOz timeout errors globally - be very aggressive
16144
16145
  const isSignOzTimeout = ((errorMessage.includes('Timeout') || errorMessage.includes('timeout') || errorMessage.includes('ETIMEDOUT')) &&
16145
16146
  (errorMessage.includes('BatchSpanProcessor') ||
16146
16147
  errorMessage.includes('OTLP') ||
@@ -16148,10 +16149,12 @@ function initializeSignOzTracing(config) {
16148
16149
  errorStack.includes('BatchSpanProcessor') ||
16149
16150
  errorStack.includes('OTLPTraceExporter') ||
16150
16151
  errorStack.includes('zone.js') ||
16151
- (source === null || source === void 0 ? void 0 : source.includes('zone.js'))));
16152
- const isGenericTimeout = (errorMessage === 'Timeout' ||
16153
- errorMessage === 'timeout' ||
16154
- (errorMessage.includes('Timeout') && errorStack.includes('zone.js')));
16152
+ errorSource.includes('zone.js') ||
16153
+ errorStack.includes('signoz') ||
16154
+ errorSource.includes('signoz')));
16155
+ // Also suppress generic timeout errors from zone.js or bundle.js
16156
+ const isGenericTimeout = ((errorMessage === 'Timeout' || errorMessage === 'timeout') ||
16157
+ (errorMessage.includes('Timeout') && (errorStack.includes('zone.js') || errorSource.includes('bundle.js'))));
16155
16158
  if (isSignOzTimeout || isGenericTimeout) {
16156
16159
  // Suppress completely - don't log, don't propagate
16157
16160
  return true; // Returning true prevents default error handling
@@ -16162,6 +16165,32 @@ function initializeSignOzTracing(config) {
16162
16165
  }
16163
16166
  return false;
16164
16167
  };
16168
+ // Also suppress unhandledrejection for timeout errors
16169
+ const originalUnhandledRejection = window.onunhandledrejection;
16170
+ window.addEventListener('unhandledrejection', function (event) {
16171
+ const reason = String(event.reason);
16172
+ const stack = event.reason instanceof Error ? (event.reason.stack || '') : '';
16173
+ const isSignOzTimeout = ((reason.includes('Timeout') || reason.includes('timeout') || reason.includes('ETIMEDOUT')) &&
16174
+ (reason.includes('BatchSpanProcessor') ||
16175
+ reason.includes('OTLP') ||
16176
+ reason.includes('exporter') ||
16177
+ stack.includes('BatchSpanProcessor') ||
16178
+ stack.includes('OTLPTraceExporter') ||
16179
+ stack.includes('zone.js') ||
16180
+ stack.includes('signoz')));
16181
+ const isGenericTimeout = (reason === 'Timeout' ||
16182
+ reason === 'timeout' ||
16183
+ (reason.includes('Timeout') && stack.includes('zone.js')));
16184
+ if (isSignOzTimeout || isGenericTimeout) {
16185
+ event.preventDefault();
16186
+ event.stopPropagation();
16187
+ event.stopImmediatePropagation();
16188
+ return;
16189
+ }
16190
+ if (originalUnhandledRejection) {
16191
+ originalUnhandledRejection.call(window, event);
16192
+ }
16193
+ }, true);
16165
16194
  // Gabungkan konfigurasi dari parameter, process.env, dan window
16166
16195
  const effectiveConfig = {
16167
16196
  serviceName: (config === null || config === void 0 ? void 0 : config.serviceName) || getConfigValue('REACT_APP_SIGNOZ_SERVICE_NAME'),
@@ -16176,9 +16205,9 @@ function initializeSignOzTracing(config) {
16176
16205
  })(),
16177
16206
  batchSpanProcessorConfig: (config === null || config === void 0 ? void 0 : config.batchSpanProcessorConfig) || {
16178
16207
  maxQueueSize: 100,
16179
- scheduledDelayMillis: 3000, // Kirim lebih cepat (3 detik)
16180
- exportTimeoutMillis: 10000, // Timeout lebih pendek (10 detik)
16181
- maxExportBatchSize: 30 // Batch lebih kecil untuk menghindari timeout
16208
+ scheduledDelayMillis: 2000, // Kirim lebih cepat (2 detik)
16209
+ exportTimeoutMillis: 3000, // Timeout lebih pendek (3 detik) untuk fail fast
16210
+ maxExportBatchSize: 20 // Batch lebih kecil untuk menghindari timeout
16182
16211
  },
16183
16212
  allowedOrigins: (config === null || config === void 0 ? void 0 : config.allowedOrigins) || parseAllowedOrigins(getConfigValue('REACT_APP_SIGNOZ_ALLOWED_ORIGINS')),
16184
16213
  enableRequestLogging: (config === null || config === void 0 ? void 0 : config.enableRequestLogging) !== undefined ? config.enableRequestLogging : (getConfigValue('REACT_APP_SIGNOZ_ENABLE_REQUEST_LOGGING') === 'true' || true),
@@ -16212,41 +16241,63 @@ function initializeSignOzTracing(config) {
16212
16241
  const exporter = new OTLPTraceExporter({
16213
16242
  url: effectiveConfig.url,
16214
16243
  headers: effectiveConfig.headers,
16215
- timeoutMillis: 10000 // Timeout lebih pendek (10 detik)
16244
+ timeoutMillis: 3000 // Timeout lebih pendek (3 detik) untuk fail fast
16216
16245
  });
16217
- // Wrap exporter to suppress timeout errors completely
16246
+ // Wrap exporter to suppress timeout errors completely and prevent them from reaching Zone.js
16218
16247
  const originalExport = exporter.export.bind(exporter);
16248
+ let timeoutWarningShown = false;
16219
16249
  exporter.export = function (spans, resultCallback) {
16220
- // Wrap in try-catch to prevent any errors from propagating
16250
+ let callbackInvoked = false;
16251
+ const safeCallback = (result) => {
16252
+ if (callbackInvoked)
16253
+ return;
16254
+ callbackInvoked = true;
16255
+ try {
16256
+ resultCallback(result);
16257
+ }
16258
+ catch (e) {
16259
+ // Suppress any errors from the callback itself
16260
+ }
16261
+ };
16262
+ // Set a timeout to force success callback BEFORE the actual timeout occurs
16263
+ const timeoutId = setTimeout(() => {
16264
+ if (!timeoutWarningShown && effectiveConfig.enableConsoleLog) {
16265
+ console.warn('[SignOz] Span export timeout - check if SignOz endpoint is reachable:', effectiveConfig.url);
16266
+ timeoutWarningShown = true;
16267
+ }
16268
+ // Force success callback to prevent error propagation
16269
+ safeCallback({ code: 0 });
16270
+ }, 2500); // Trigger before the 3s exporter timeout
16221
16271
  try {
16222
16272
  originalExport(spans, (result) => {
16223
- // Suppress ALL errors to prevent console noise and Zone.js catching them
16273
+ clearTimeout(timeoutId);
16274
+ // Always treat as success to prevent any error propagation
16224
16275
  if (result.error) {
16225
16276
  const errorMessage = String(result.error);
16226
- if (errorMessage.includes('Timeout') || errorMessage.includes('timeout') || errorMessage.includes('ETIMEDOUT')) {
16227
- if (effectiveConfig.enableConsoleLog) {
16277
+ if (!timeoutWarningShown && effectiveConfig.enableConsoleLog) {
16278
+ if (errorMessage.includes('Timeout') || errorMessage.includes('timeout') || errorMessage.includes('ETIMEDOUT')) {
16228
16279
  console.warn('[SignOz] Span export timeout - check if SignOz endpoint is reachable:', effectiveConfig.url);
16229
16280
  }
16230
- // Call callback with success to prevent error propagation
16231
- resultCallback({ code: 0 });
16232
- return;
16233
- }
16234
- // For other errors, also suppress but log if console logging is enabled
16235
- if (effectiveConfig.enableConsoleLog) {
16236
- console.warn('[SignOz] Span export error (suppressed):', errorMessage);
16281
+ else {
16282
+ console.warn('[SignOz] Span export error (suppressed):', errorMessage);
16283
+ }
16284
+ timeoutWarningShown = true;
16237
16285
  }
16238
- resultCallback({ code: 0 });
16286
+ // Always return success to prevent error propagation
16287
+ safeCallback({ code: 0 });
16239
16288
  return;
16240
16289
  }
16241
- resultCallback(result);
16290
+ safeCallback(result);
16242
16291
  });
16243
16292
  }
16244
16293
  catch (error) {
16294
+ clearTimeout(timeoutId);
16245
16295
  // Catch any synchronous errors and suppress them
16246
- if (effectiveConfig.enableConsoleLog) {
16296
+ if (!timeoutWarningShown && effectiveConfig.enableConsoleLog) {
16247
16297
  console.warn('[SignOz] Span export exception (suppressed):', error);
16298
+ timeoutWarningShown = true;
16248
16299
  }
16249
- resultCallback({ code: 0 });
16300
+ safeCallback({ code: 0 });
16250
16301
  }
16251
16302
  };
16252
16303
  // Set up the span processor with configuration