Comments (6)
I think this is very unlikely to be an issue in the js-sdk-common
code. I mean, we could consider logging the error differently there as you suggested, but if it is getting malformed JSON in a stream message then the problem has got to be further upstream, either in the LaunchDarkly streaming service or in some infrastructure in between. The code here does not have any influence over how stream messages are received— that is done either by the browser's built-in EventSource component, or by an EventSource polyfill if you're using one.
I think that the best way to investigate this would be to go through the support team at support.launchdarkly.com. That investigation may still include looking into JS SDK code, in which case I'll still be involved, but I think the scope is unlikely to be limited to that. For instance, even though I don't think "a wrong flag value" could cause this (no matter what the flag values are, they are encoded to JSON using the same mechanism, which cannot produce malformed JSON— that would have to involve some kind of error in transmission), if we do need to look at your flag data I have no way to do that in the context of a GitHub issue.
from js-sdk-common.
Also, regarding the error logging, I'm not clear on what "proxied to the consumer in a more descriptive manner" would mean. If invalid stream data was received, there is not much else to say or do about it— the SDK needs to restart the stream because otherwise it can't guarantee it hasn't missed any important data.
from js-sdk-common.
Thank you for the response @eli-darkly .
By "proxied to the consumer in a more descriptive manner" I meant that the LD SDK could, hypothetically, handle the error and "re-throw" it to the consumer (our application) with a defined and documented signature, so our application is aware what's going on and can react accordingly. Otherwise the only way to get rid of the error on our side is to suppress it globally but that could also suppress other JSON.parse errors too eagerly if they happen.
Anyway, I suggested it before your answer, so after your explanation I understand it wouldn't be the case anymore because the error might not be coming from the flag data as I understand.
I guess I'll move on with this issue through the support team.
from js-sdk-common.
I meant that the LD SDK could, hypothetically, handle the error and "re-throw" it to the consumer (our application) with a defined and documented signature, so our application is aware what's going on and can react accordingly
The problem is that there isn't anywhere to re-throw it to, because this is not happening inside of a method that was called by the application. The task of receiving stream data from LaunchDarkly happens in the background; at that point in the SDK code, there is no application code higher up in the call stack, and any uncaught exceptions would either fall into the void or turn into unhandled promise rejections. (Also, as a general rule we do not want to throw exceptions from the SDK into application code, because we want usage of the SDK to be very simple and transparent, so developers can add flag evaluations throughout their existing code and not worry that there could be an unexpected early exit from a code path.)
If you didn't mean literally "throw", but just provide some kind of notification mechanism— that sounds a bit like the "connection status" or "data source status" API that exists in some of the SDKs, for instance in Java, which reports any kind of problem with the SDK's connection to LD, which could be a network issue or bad data, etc. We're in the process of adding that feature to other SDKs and we may consider implementing an event-based mechanism in the JS SDK for a similar purpose, although it would probably be simpler because 1. we want to keep this SDK relatively lightweight and 2. we have much less ability to inspect or control the stream connection, due to the use of the browser's EventSource.
from js-sdk-common.
@matewka what did the support team say? We are seeing this same error but caught only in our production Sentry logs.
from js-sdk-common.
@dsteinbach-ep all I know about this issue is in the thread. Plus I don't work in that company anymore.
from js-sdk-common.
Related Issues (20)
- Source maps reference files not published to NPM HOT 1
- Types could catch invalid contexts at build time HOT 1
- Type-safe feature flags HOT 13
- Store hash value not updated by ldClient.identify() HOT 4
- uuid package needs upgrade to version 7+ HOT 5
- Library does not catch errors when changing localstorage HOT 7
- Mistake in type docs about omit user key HOT 5
- JSON.Parse unhandled errors happening for a small % of our clients HOT 1
- Re-bootstrap on identify HOT 10
- TypeErrors in diagnosticEvents HOT 5
- Expose a hook to surface when fresh flags have been fetched HOT 5
- consider correcting typing of `LDOptions`'s `bootstrap` HOT 7
- Network requests to fetch flags are not retried unless the client successfully retrieves flags from localStorage HOT 1
- Node circular dependency warning on 4.x branch HOT 2
- Adding missing type definitions "inExperiment" HOT 1
- LDContext type is incorrect and errors when accessing `kind` property HOT 4
- Use `unknown` instead of `any` HOT 1
- `events.slice` is not a function HOT 4
- Node process hangs before exiting HOT 12
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from js-sdk-common.