launchdarkly / react-client-sdk

LaunchDarkly Client-side SDK for React.js
Other
81 stars 67 forks source link

Sentry reporting LaunchDarklyFlagFetchError #106

Open pratishshr opened 2 years ago

pratishshr commented 2 years ago

Describe the bug We are getting this error in Sentry currently in production. Is this any chance because of the SDK ?

image

To reproduce Not sure, it's only reported by Sentry in production app

Expected behavior Should not report the error

Logs If applicable, add any log output related to your problem.

SDK version

"launchdarkly-react-client-sdk": "^2.23.3",

Language version, developer tools

OS/platform It mostly occurs in Mobile Safari and Snapchat webviews

Additional context Add any other context about the problem here.

eli-darkly commented 2 years ago

If your question is "does the error called 'LaunchDarklyFlagFetchError' ever get logged by the LaunchDarkly SDK" then the answer is yes, that is how the SDK reports that a network request has failed.

If your question is "why did a network request fail", it's impossible to answer that question from only the information you've given here. All I can see is that it is not the result of the request you showed in that screenshot, the one to events.launchdarkly.com, because that request is delivering diagnostic data to LaunchDarkly; "LaunchDarklyFlagFetchError", as the name implies, is only for the failure of a request to get flags from LaunchDarkly. That request would be to either app.launchdarkly.com or clientsdk.launchdarkly.com.

eli-darkly commented 2 years ago

Is Sentry not showing you any information about a failed HTTP request?

pratishshr commented 2 years ago

Ah right, sorry. Here's the breadcrumb of the error.

image image

Looks like it errored out while fetching nextjs static content and data. image

Full raw error:

LaunchDarklyFlagFetchError: network error (Error)
  at o(./node_modules/launchdarkly-js-client-sdk/dist/ldclient.es.js:1:1061)
  at call(./node_modules/launchdarkly-js-client-sdk/dist/ldclient.es.js:1:1324)
  at __webpack_require__(webpack://_N_E/webpack/bootstrap:21:33)
  at call(./node_modules/launchdarkly-react-client-sdk/lib/initLDClient.js:50:36)
  at __webpack_require__(webpack://_N_E/webpack/bootstrap:21:33)
  at call(./node_modules/launchdarkly-react-client-sdk/lib/provider.js:88:38)
  at __webpack_require__(webpack://_N_E/webpack/bootstrap:21:33)
  at call(./node_modules/launchdarkly-react-client-sdk/lib/index.js:7:34)
  at __webpack_require__(webpack://_N_E/webpack/bootstrap:21:33)
  at call(chunks/pages/_app-4b5e9a9166ccb2649421.js:17:30)
  at __webpack_require__(webpack://_N_E/webpack/bootstrap:21:33)
  at ? (chunks/pages/_app-4b5e9a9166ccb2649421.js:5:16)
  at promiseReactionJob([native code])

Also, it seems to only happen with Safari on iPhone and Snapchat webview.

image

francescov1 commented 2 years ago

+1 seeing this as well

grgilad commented 2 years ago

Can see this on a multi-day basis: LaunchDarklyFlagFetchError: network error (Error) at ? (../../node_modules/launchdarkly-js-sdk-common/dist/ldclient-common.es.js:1:16981)

joshketellapper commented 2 years ago

+1 see this too

eli-darkly commented 2 years ago

Well, again, this is an extremely general kind of error report. It is expected and correct for the SDK to log that there was a network error, if in fact there was a network error. I have no way to know whether the actual cause is the same or different for the several users who have commented here. The Sentry information posted by @pratishsr earlier does seem to indicate that there was some kind of I/O error (that is, "Encountered an unexpected network error from axios: Network error" does not seem to be just a duplicate of the message from the LaunchDarkly SDK) but unfortunately it's not providing any other details.

louis-launchdarkly commented 2 years ago

Hello @francescov1, @grgilad, and @joshketellapper, thank you for reaching out on this issue too. Do you have any further information like stack track, what kind of environment and browser your app runs in, time and frequency that the error occurs, React SDK version?

We will need more information to help narrow down what's going on so I appreciate any input.

grgilad commented 2 years ago

Here's an example: GET https://app.launchdarkly.com/sdk/evalx/602488fac930a30b0067eaeb/users/eyJhbm9ueW1vdXMiOnRydWUsImtleSI6IjRiOWYwMDUxLTZjZDgtMTFlYy04M2RjLTVmNDcwZDJjYjU3MSJ9

Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.45 Safari/537.36

launchdarkly-react-client-sdk - 2.23.3

eli-darkly commented 2 years ago

@grgilad That is a valid URL and I have no problem accessing it with any client. It's hard to think of any way that the SDK itself could cause "network error" to be logged unless there was in fact a network error (or something else interfering with the browser in a way that manifests as a network error). The SDK does pretty ordinary HTTP requests. Do you have reason to believe that it's only the LaunchDarkly SDK that is having problems like this in your environment?

francescov1 commented 2 years ago

@louis-launchdarkly

We haven't had any other network errors reported other than from LD. Additionally, this seems to be occurring almost solely in Snapchat webviews, with a few events in mobile safari as well. Error info looks pretty much the same as @pratishshr.

We've got a reported code field that is undefined; is that normal? Would be nice to have some way to determine if it was just a transient network error or anything else.

Screen Shot 2022-01-09 at 9 37 22 AM

If this is just a regular network failure (or anything else), is there any extra handling we need to do? If the SDK auto-retries in this case then it seems pointless to report or pay attention to these errors, otherwise we should probably implement our own retry strategy.

yufio commented 1 year ago

@francescov1 did you manage to find the reason behind this? We have used LD for more than a year and recently (~ 1-1.5 months ago) started seeing this error relatively often. We've got the same response from LD that it is possible to get this error but we also struggle to understand how this can happen since there's no indication that other requests fail. I am wondering if it is related to people using ad blockers maybe 🤔

francescov1 commented 1 year ago

@yufio Unfortunately not, still seeing it occur. I could see it being an ad blocker issue.

immutable-pro commented 1 year ago

Greetings! I can confirm that in Rapid Studio, we keep seeing this in Safari and all iOS browsers (Safari based).

scaniflubacher commented 1 year ago

+1 -- we're seeing this as well. Seems to be macOS and iOS clients only. Happy to provide any supporting information that may be helpful.

patt-prabha commented 1 year ago

+1 We are also seeing the same errors in huge numbers.

Twipped commented 1 year ago

We recently started seeing this issue, and I believe it is caused by the use of a synchronous xhr request on page close. The use of synchronous requests is deprecated by many browsers [1], and Webkit explicitly disallows sync XHR on page dismissal [2].

This code should be changed to use the navigator.sendBeacon API to dispatch these page close events.

EDIT: Just saw this issue, so clearly y'all know about it. 😅

slgriffiths commented 1 year ago

+1 Also seeing it frequently since migrating to Next.js.

sourceful-david commented 1 year ago

+1 We are also seeing huge numbers of these using Nextjs

NateDawg90 commented 1 year ago

+1 Any update on this? We will likely not be able to use a client side Launch Darkly implementation until this issue is resolved.

scaniflubacher commented 1 year ago

I think I eliminated this issue by turning off the options that are sending data back to the mother ship.. diagnosticOptOut: true, sendEvents: false,

Netacci commented 10 months ago

Fixed this issue to stop reporting to sentry by adding a catch block to my launchdarkly initialization ldClient .identify({ key: key, name: username, }) .catch((error) => { console.error('Caught Error:', error.message); });

OptoGreg commented 10 months ago

We'd like to have the event tracking, but not get sentry flooded with messages when network errors occur.

lizhenew commented 10 months ago

I see that js-client-sdk has fixed this issue in version3.1.4 .When will react-client-sdk update its dependency version on this package? @yusinto