flutter-client-sdk
flutter-client-sdk copied to clipboard
Errors when using Web Assembly (wasm)
Is this a support request? Yes
Describe the bug I have migrated our web project to web assembly (wasm), and after that, I am getting several CORS errors on launch darkly.
To reproduce
Add the launchdarkly_flutter_client_sdk: ^4.7.0 on a web project make all required configurations and build it for wasm. When you try to access the web version, you will get a bunch of CORS errors.
Expected behavior No CORS errors.
Logs Error from the browser
GET https://clientstream.launchdarkly.com/eval//eyJraW5kIjoibXVsdGkiLCJkZXZpY2UiOnsia2V5IjoiY2UzZDAwNDMtMjNhNy00NGNjLTlkYmMtZjM2N2E5ODg0MDAyIiwiYW5vbnltb3VzIjp0cnVlfSwibGRfYXBwbGljYXRpb24iOnsia2V5IjoiSER0MHlYc2RpbjZrbFBNcGlpaElUdVNIeFpOMG5yVktLVlpzemdIdWNJWT0iLCJuYW1lIjoib3R0b19hcHAiLCJpZCI6Im90dG9fYXBwIiwidmVyc2lvbk5hbWUiOiIxLjcuMyIsImxvY2FsZSI6ImVuLVVTIiwiZW52QXR0cmlidXRlc1ZlcnNpb24iOiIxLjAifX0= net::ERR_FAILED 301 (Moved Permanently)Understand this errorAI
192.168.3.109/:1 Access to resource at 'https://clientstream.launchdarkly.com/eval//eyJraW5kIjoibXVsdGkiLCJkZXZpY2UiOnsia2V5IjoiY2UzZDAwNDMtMjNhNy00NGNjLTlkYmMtZjM2N2E5ODg0MDAyIiwiYW5vbnltb3VzIjp0cnVlfSwibGRfYXBwbGljYXRpb24iOnsia2V5IjoiSER0MHlYc2RpbjZrbFBNcGlpaElUdVNIeFpOMG5yVktLVlpzemdIdWNJWT0iLCJuYW1lIjoib3R0b19hcHAiLCJpZCI6Im90dG9fYXBwIiwidmVyc2lvbk5hbWUiOiIxLjcuMyIsImxvY2FsZSI6ImVuLVVTIiwiZW52QXR0cmlidXRlc1ZlcnNpb24iOiIxLjAifX0=' from origin 'https://192.168.3.109' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
// Most relevant part of the error:
No 'Access-Control-Allow-Origin' header is present on the requested resource.
SDK version 4.7.0
Language version, developer tools Flutter 3.27.0 Framework • revision 8495dee1fd (5 weeks ago) • 2024-12-10 14:23:39 -0800 Engine • revision 83bacfc525 Tools • Dart 3.6.0 • DevTools 2.40.2
Additional context This error doesn't happen if I use normal web build, it only happens when I use wasm to build. It successful build, but we got these errors.
Another weird thing that we discovered is that when we are using the WASM build, the failing CORS requests of launch darkly are going with the wrong URL, like this:
https://clientstream.launchdarkly.com/eval//eyJra...... -> Look after the eval. I believe there should appear the client ID. It's important enforce that if we use normal web builds (no wasm) this error doesn't happens.
I am seeing this as well. Any updates to this?
Hello @luizpaulofranz and @alexdecoder, thank you for reporting this issue. Sorry that it took a while to respond to this. We have opened a ticket and will try to look into the issue. Does either of you have a sample project that can help us reproduce this faster?
Filed internally as SDK-1093.
Is there any update on this issue?
Sorry for the slow reply, the investigation so far found the current Flutter SDK is using a dependency (dart:html) that is not Web Assembly compatible. We are looking to replace that dependency and make sure the SDK still builds correctly for all platforms.
Thank you for your answer. As far as I'm aware, Flutter has instructions on how to migrate from dart:html to package:web published on their site. If help from the community is needed, let us know.
@luizpaulofranz @alexdecoder @sunderee launchdarkly_flutter_client_sdk version 4.11.0 has just been released to add support for WASM when using Flutter version 3.24.0 or higher.
@luizpaulofranz @abarker-launchdarkly, even after upgrading to the latest version, I am seeing the below CORS errors:
@alexdecoder I want to try and eliminate variables here. Can you do the following:
git clone https://github.com/launchdarkly/flutter-client-sdk.gitcd flutter-client-sdk/packages/flutter_client_sdk/exampleflutter pub getflutter run --dart-define LAUNCHDARKLY_CLIENT_SIDE_ID=<<insert your client id here>> -d Chrome --wasm
This should work with no errors and your network traffic should look similar to this: