Skip to content

HTTP Requests to example.com on Sentry.init #18218

@AwolDes

Description

@AwolDes

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/browser

SDK Version

8.34.0

Framework Version

No response

Link to Sentry event

https://tandahq.sentry.io/issues/6950814233/?project=4507847337181184&query=is%3Aunresolved&referrer=issue-stream

Reproduction Example/SDK Setup

We have been getting this error in production when Sentry is initially configured:

Image

I believe this is because of this method checking the browser can use fetch:

new Request('http://www.example.com');

This has caused 1.1m errors in the last few weeks & I would like to understand if there's a reason this needs to be the http endpoint? The only issue I found somewhat related to this is about e2e tests in #15052

I have a draft PR here: #18217

Steps to Reproduce

This is my sentry.js

// @flow
import * as Sentry from "@sentry/browser"

const enabledEnvironments = ["development", "staging", "production"]

const isEnabled = enabledEnvironments.includes(process.env.TARGET_RAILS_ENV)
const commitSha = process.env.COMMIT_SHA || "unknown"
const payausUrls = [/https?:\/\/.*\.tanda\.co/, /https?:\/\/.*\.workforce\.com/]

if (isEnabled) {
  Sentry.init({
    dsn: "our_dsn",
    release: `${commitSha}`,
    environment: process.env.TARGET_RAILS_ENV,
    allowUrls: payausUrls,

    // This is error sampling:
    // https://docs.sentry.io/platforms/javascript/configuration/options/#sample-rate
    sampleRate: 1,

    // No perf sampling from frontend.
    // https://docs.sentry.io/platforms/javascript/configuration/options/#tracing-options
    enableTracing: true,
    tracesSampleRate: 0,
    tracePropagationTargets: payausUrls,

    ignoreErrors: [
      "__gCrWeb.autofill.extractForms",
      "Background Sync is disabled",
      "Request failed with status code",
      "__firefox__",
      /maininit|\$/,
      "_isMatchingDomain is not defined",
      "Failed to execute 'postMessage' on 'Window':",
      "AbortError",
      "createError",
      "node_modules",
      "AxiosError", // Added but unsure it would even mute the error if it's happening during `init`
    ],
    denyUrls: ["js.intercomcdn.com"],
    beforeSend(event) {
      if (event.user) {
        delete event.user.username
        delete event.user.email
      }

      return event
    },
  })

  window.current_user && Sentry.setUser({ id: window.current_user.id })

  const euUrl = /^https?:\/\/.*.?eu\.(workforce|tanda)/
  const region = window.location.href.match(euUrl) ? "frankfurt" : "sydney"

  Sentry.setTag("region", region)
}

Expected Result

No error

Actual Result

Errors every time Sentry is initialised

Additional Context

Tip: React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it.

Image

Metadata

Metadata

Assignees

No one assigned

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions