flagsmith-js-client icon indicating copy to clipboard operation
flagsmith-js-client copied to clipboard

Uncaught rejected promise when attempting to fetch flags while offline

Open frankieyan opened this issue 1 year ago • 1 comments

Hi there 👋 I'm seeing an uncaught rejection when calling Flagsmith.init while offline.

image image

It seems to be coming from this call: https://github.com/Flagsmith/flagsmith-js-client/blob/f2c29640991df6428c2603d98da7f847276dd4fd/flagsmith-core.ts#L447-L449

It doesn't cause any real issues as flags are still resolved correctly from local storage, and since the user is likely offline when this happens, it may not affect our telemetry. However, since it's not an error that can be caught in user land, perhaps it'd make more sense to handle the rejection and only reject from init() if the cache fails.

Please let me know if you need more details, thank you!

frankieyan avatar Sep 13 '24 03:09 frankieyan

Hi @frankieyan, thanks for raising this. I think your suggestion here makes sense

handle the rejection and only reject from init() if the cache fails

Would you be willing to submit a PR for this?

matthewelwell avatar Sep 13 '24 07:09 matthewelwell