GodotNuts / GodotFirebase

Implementations of Firebase for Godot using GDScript
MIT License
517 stars 74 forks source link

[ISSUE] Send an error to console when there is no response (HTML5) #378

Closed thiscris closed 6 months ago

thiscris commented 6 months ago

Is your feature request related to a problem? Please describe. I have a connection that works fine when tested in Godot editor and when the project is exported as a standalone application. When exported as an HTML5 or running in a remote debug browser, the same Firebase.Auth.signup_succeeded signal does not fire up. Neither the browser console nor the Godot editor output provide any information

Describe the solution you'd like I believe that we need a Firebase._printerr() for the cases where the response_code is 0 Original code inside auth.gd starting at line 406:

func _on_FirebaseAuth_request_completed(result : int, response_code : int, headers : PackedStringArray, body : PackedByteArray) -> void:
    var json = Utilities.get_json_data(body.get_string_from_utf8())
    is_busy = false
    var res
    if response_code == 0:
        # Mocked error results to trigger the correct signal.
        # Can occur if there is no internet connection, or the service is down,
        # in which case there is no json_body (and thus parsing would fail).
        res = {"error": {
            "code": "Connection error",
            "message": "Error connecting to auth serviceError connecting to auth service"}}
    else:
...

Describe alternatives you've considered Following the wiki for authenticating , I added signal listeners for failed sign in and failed log in. I assumed that the same signals are emitted when doing anonymous sign up, but they don't seem to receive anything either.

Additional context In my exporting parameters I added *.env , .env to the resourses to export, just to be double sure. Looking at my Firebase console, I can see that the HTML5 runnable is reaching Firebase as new anonymous users are created when I test it. This leads me to believe that there is no issue with the .env file or the CORS request. I still haven't tried:

WolfgangSenff commented 6 months ago

Are you just asking to print something in the same place where the response is 0 - where you showed the code? I'm happy to add that, just want to make sure.

thiscris commented 6 months ago

I believe that it might reduce headaches for people. I had to dig in the addon and add my own print statement inside _on_FirebaseAuth_request_completed to find out what is (not) happening. Even with that I still don't know how to deal with my HTML5 issue, but maybe I could open a separate bug for that?

WolfgangSenff commented 6 months ago

I can attempt to figure out a fix for that here, too. I might need more info though. What browser are you using, and do you get any errors in your browser tools? (On Chrome, for instance, you can open the developer tools with "ctrl + shift + i".)

thiscris commented 6 months ago

I am using Chromium on Ubuntu. Using FirebaseTestHarness as a minimal project to replicate the issue. First run from the editor - success FirebaseTestHarness-editor

Second run by setting an export preset Web and using "Remote debug - Run in Browser" - failure FirebaseTestHarness-html5

(I have to go to the Firebase console and delete the newly created users before each test) My preset include " *.env, .env " and am exporting with debugging. In the console there are many error messages. The only relevant one appears to be error 400 - bad request. I am attaching the full log that is 1865 lines, but here is a screenshot of the area that appears relevant: (edit: removed)

Thank you very much for the proposed help. I am out of ideas how to continue.

WolfgangSenff commented 6 months ago

Hm, very curious. I'll have to look into it and don't have time right now, but you can switch this from a feature request to a bug and I will try to get to it soon. This is pretty strange. The auth file thing is expected, but the bad request is not, so it's weird. You can delete your screen shot and the log from your post though - while you can/should lock down your rules so it doesn't really matter, generally speaking your key being available there is not great, so go ahead and delete them for now (I have the file that's relevant and will use it to try to fix this). You can ping me on Discord, if you're on there, in the future if you have files to send like that. I'm BackAt50Ft there, in the GodotNuts server.

thiscris commented 6 months ago

Thank you for pointing it out. I regenerated a new API key and modified the .env files to practice this scenario. Followed these steps from stackoverflow https://stackoverflow.com/a/61756568

WolfgangSenff commented 6 months ago

This is a bug in what you're doing. Looking at the above, it is expected! You need to delete your email between logins if you are trying to sign up multiple times. I described how to do this in the Discord server, so I'm going to close this.

thiscris commented 6 months ago

I am sorry @WolfgangSenff , but I disagree. As described in my comment 4 days ago https://github.com/GodotNuts/GodotFirebase/issues/378#issuecomment-1890954453 , I was cleaning the users list before every test and after your comment about not skipping this, I repeated the tests properly and the issue is still present. I suggest to reopen the bug.

So far we have tested: