Closed linhdogg closed 3 years ago
Hi @linhdogg
can you please provide your flutter doctor -v
,
your flutter run --verbose
your pubspec.yaml
,
and a reproducible minimal code sample.
Thank you
Hi @iapicca
this is flutter doctor -v
pubspec.yaml
version: 1.0.0+1
environment:
sdk: ">=2.6.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
dartz: ^0.9.0-dev.6
freezed_annotation: ^0.7.1
uuid: ^2.0.4
flutter_bloc: ^3.2.0
auto_route: ^0.4.4
get_it: ^3.1.0
meta: ^1.1.8
algolia: ^0.1.7
google_maps: ^3.4.1
firebase_core: 0.4.4
firebase_auth: 0.15.3
google_sign_in: ^4.1.1
cloud_firestore: ^0.13.5
cloud_functions: ^0.5.0
cloud_functions_web: ^1.1.0
injectable: ^0.3.0
flushbar: ^1.10.0
intl: ^0.16.1
timeago: ^2.0.26
json_annotation: ^3.0.1
google_maps_flutter: ^0.5.27
google_maps_flutter_platform_interface: ^1.0.1
styled_widget: ^0.1.1
flutter_hooks: ^0.8.0
time: ^1.2.0
kt_dart: ^0.7.0
rxdart: ^0.23.1
dash_chat: ^1.1.1
reorderables: ^0.2.12
responsive_builder: ^0.1.2
provider: ^4.0.4
carousel_slider: ^2.0.0
smooth_star_rating: 1.0.4+2
implicitly_animated_reorderable_list: ^0.1.9
flutter_slidable: ^0.5.4
dev_dependencies:
flutter_test:
sdk: flutter
mockito: ^4.1.1
cloud_firestore_mocks: ^0.4.2
lint: ^1.1.1
build_runner:
freezed: ^0.9.2
auto_route_generator: ^0.4.5
injectable_generator: ^0.3.2
json_serializable: ^3.2.5
Looks like it may be related to https://github.com/FirebaseExtended/flutterfire/pull/2706 and https://github.com/FirebaseExtended/flutterfire/pull/2556
Make sure you have the right version in index.html (per https://pub.dev/packages/cloud_functions_web) :
<script src="https://www.gstatic.com/firebasejs/7.6.2/firebase-functions.js"></script>
instead of
<script src="https://www.gstatic.com/firebasejs/7.21.1/firebase-functions.js"></script>
I upgraded all of my firebase js dependencies and cloud functions stopped working after that. Had no clue that this was the issue.
I'm also getting this FirebaseError: internal (internal)
I've adjusted my firebase-functions.js
import to 7.6.2
however I am still getting the error.
Any solution to this? I got the same error.
Is there any news or workarounds for this yet?
I tried rolling back everything to an older version (0.8.0 cloud_functions and compatible rest of libraries) and it still doesn't work. Even the most simple form of cloud functions trigger this internal exception.
I tried rolling back everything to an older version (0.8.0 cloud_functions and compatible rest of libraries) and it still doesn't work. Even the most simple form of cloud functions trigger this internal exception.
Do you have the right version in index.html ?
I tried rolling back everything to an older version (0.8.0 cloud_functions and compatible rest of libraries) and it still doesn't work. Even the most simple form of cloud functions trigger this internal exception.
Do you have the right version in index.html ?
Yes, same issue. Internal error. This happens with both local emulator and deployed functions. The thing is that the functions are executed successfully (I can see it in the logs). It's just that the flutter functions library throws this exception afterwards.
@GyuriMajercsik I found the issue, but with my limited web skills I have no idea how to fix it:
Access to fetch at 'http://localhost:5001/*******' from origin 'http://localhost:37349' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
Ok, so if you're hitting the CORS issue, it seems that the function is getting triggered on the OPTIONS request the browser is making. You need to return the standard CORS response and then the browser will make the normal request using POST.
Seems 7.22.0
version is broken for cloud functions, but for 7.22.1
, it is working.
It is not working for me on any version, I cannot believe it is still not fixed and it has been about a year now.
@markusaksli-nc, @linhdogg,@alexandru-g has anyone found any workaround for this? Or is there anyone working on this issue?
@vishnuagbly as a temporary workaround, in your cloud functions, check first if it's an OPTIONS type of request and return 200. The normal POST will work correctly afterwards.
@alexandru-g since we are using firebase cloud functions our cloud function looks like this
const functions = require('firebase-functions');
exports.listFruit = functions.https.onCall((data, context) => {
return ["Apple", "Banana", "Cherry", "Date", "Fig", "Grapes"]
});
I don't know how to do that here 😥
@vishnuagbly you can also use onRequest
instead of onCall
. Please see the documentation: https://firebase.google.com/docs/functions/get-started#add-the-addmessage-function.
In the example above you can check the type of request in the req
object. Also, please make sure you set the appropriate CORS headers. Something like:
export const someFunction = functions.https.onRequest((request, response) => {
response.set({
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': 'GET,PUT,POST,DELETE,PATCH,OPTIONS',
'Access-Control-Allow-Headers': 'Origin, X-Requested-With, Content-Type, Accept, Authorization',
});
if (request.method == "OPTIONS") {
response.sendStatus(200);
return;
}
// Your normal function execution
}
I had no problem by doing the above, but it's just a workaround.
Stunning that this show stopping, critical bug hasn't been fixed. Sours me on the whole not-ready-for-prime-time Google cloud ecosystem. Disclosure: I submitted #5428 (now closed as a duplicate) after spending a week looking for a work-around. Did not find a work-around. No combination of cloud_functions and JS versions works for me.
@alexandru-g unfortunately I cannot use your workaround as I need the context object to check for firebase authorization and uid, and for which I don't have enough knowledge to implement it by myself using HTTP requests.
I fixed it, at least for me.
1) I used 7.14.2
version same as in the cloud functions package example.
2) I think we also need to make sure that firebase-app and firebase functions js files are of same version, as I changed both to 7.14.2
and it worked.
@vishnuagbly I'm still seeing the problem (that is, I'm still seeing the internal exception). Would you let me know more precisely the two locations where you sync'd up the js versions? Index.html in the app and ??
I'd like to make sure that I'm doing the same thing. Thanks in advance!
@hallr-boulder, This is my index.html file now, I changed just this
<!DOCTYPE html>
<html>
<head>
<!--
If you are serving your web app in a path other than the root, change the
href value below to reflect the base path you are serving from.
The path provided below has to start and end with a slash "/" in order for
it to work correctly.
Fore more details:
* https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base
-->
<base href="/">
<meta charset="UTF-8">
<meta content="IE=Edge" http-equiv="X-UA-Compatible">
<meta name="description" content="A new Flutter project.">
<!-- iOS meta tags & icons -->
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="apple-mobile-web-app-title" content="appName">
<meta name="google-signin-client_id" content="<GOOGLE_SIGN_IN_API_KEY>">
<link rel="apple-touch-icon" href="icons/Icon-192.png">
<!-- Favicon -->
<link rel="icon" type="image/png" href="favicon.png"/>
<title>appName</title>
<link rel="manifest" href="manifest.json">
</head>
<body>
<!-- The core Firebase JS SDK is always required and must be listed first -->
<script src="https://www.gstatic.com/firebasejs/7.14.4/firebase-app.js"></script>
<script src="/__/firebase/8.3.1/firebase-analytics.js"></script>
<script src="https://www.gstatic.com/firebasejs/7.20.0/firebase-firestore.js"></script>
<script src="https://www.gstatic.com/firebasejs/7.20.0/firebase-auth.js"></script>
<script src="https://www.gstatic.com/firebasejs/7.14.4/firebase-functions.js"></script>
<!-- Initialize Firebase -->
<script>
const firebaseConfig = {
//copied from firbase console -> project_settings -> web_app -> config
};
// Initialize Firebase
firebase.initializeApp(firebaseConfig);
</script>
<!-- This script installs service_worker.js to provide PWA functionality to
application. For more information, see:
https://developers.google.com/web/fundamentals/primers/service-workers -->
<script>
if ('serviceWorker' in navigator) {
window.addEventListener('flutter-first-frame', function () {
navigator.serviceWorker.register('flutter_service_worker.js');
});
}
</script>
<script src="main.dart.js" type="application/javascript"></script>
</body>
</html>
This was my commit:-
@vishnuagbly Thanks for the additional information! Still no luck however. Still getting the internal exception. Very puzzling.
I feel like flutter should provide more information than the internal exception.
This is broken for me too, can't get any onCall function to work, no matter if the flutter web app is on localhost or deployed to https, I always get a CORS policy error
<script src="https://www.gstatic.com/firebasejs/7.20.0/firebase-app.js"></script>
<script src="https://www.gstatic.com/firebasejs/7.20.0/firebase-firestore.js"></script>
<script src="https://www.gstatic.com/firebasejs/7.20.0/firebase-analytics.js"></script>
<script src="https://www.gstatic.com/firebasejs/7.20.0/firebase-functions.js"></script>
These are the versions of firebase I have in my index.html
Hey folks, I've just confirmed this works on web. Please ensure you're using the following scripts in your index.html
file as per the documentation:
<script src="https://www.gstatic.com/firebasejs/8.4.1/firebase-app.js"></script>
<script src="https://www.gstatic.com/firebasejs/8.4.1/firebase-functions.js"></script>
along with the latest functions
version as per documentation:
firebase_core: "^1.0.4"
cloud_functions: "^1.0.4"
@russellwheatley Still fails (internal exception) for me using JS 8.4.1 and latest versions of firebase_core & cloud_functions.
This bug seems to be dependent on something that we're missing/not seeing. Super hard to say without debugging the js:
@russellwheatley I don't think the bug should be closed just because the code works for you. Can you provide details of your configuration (Flutter doctor) so that I can see what might be different? Thanks!
I also have the same issue but it works before user logs in to google. As soon as _firebaseAuth.signInWithCredential succeeds, all subsequent calls show FirebaseFunctionsException with 'internal' as the error. Anyone any idea?
Describe the bug Im trying to call a cloud function which returns Auth User Data but getting an error "Internal". It does not show neither error code nor error details. To Reproduce Steps to reproduce the behavior:
getUserAuthData
and deploy it successfully.package.yaml
and add everything required inindex.html
.Expected behavior It supposes to return auth user data instead of
caught generic exception (internal)