ionic-team / capacitor

Build cross-platform Native Progressive Web Apps for iOS, Android, and the Web ⚡️
https://capacitorjs.com
MIT License
12.2k stars 1.01k forks source link

bug: introduction of http module from core stops firebase/firestore working #6534

Closed JTCorrin closed 1 year ago

JTCorrin commented 1 year ago

Bug Report

Capacitor Version

  @capacitor/cli: 4.3.0
  @capacitor/core: 4.3.0
  @capacitor/android: 4.3.0
  @capacitor/ios: 4.3.0

Platform(s)

iOS Android

Current Behavior

The addition of

CapacitorHttp: {
    enabled: true,
},

to capacitor.config.ts stops/blocks/makes fail Firebase from making firestore calls in my app. Removing the above config resumes normal behaviour

Expected Behavior

firebase should continue working as normal

Code Reproduction

I've a bunch of firestore calls which look something like the below in my app. They don't seem to work

LIVE_SESSIONS_LISTENER = sessionsQuery
    .where("status", "!=", SessionStatus.Terminated)
    .where("userId", "==", user.value.uid!)
    .onSnapshot((snapshot) => {
        populate(snapshot, "liveSessions") // For the table of sessions
        if (!snapshot.empty) {
            setSelected("session", {
                sessionId: snapshot.docs[0].id,
            })
        }
        sessionsForTable.value = getSessionsForTable(
            "user",
            userRef.id
        )
    })

Other Technical Details

npm --version output:

node --version output:

pod --version output (iOS issues only):

Additional Context

Lots of errors that looks something like this on both iOS and android:

 TO JS {"url":"https:\/\/firestore.googleapis.com\/google.firestore.v1.Firestore\/Listen\/channel?database=projects%2FMY-PROJECT%2Fdatabases%2F(default)&VER=8&RID=rpc&SID=9nR2u6nG8qTh7mXxsUpXbQ&CI=0&AID=0&TYPE=xmlhttp&zx=m5em9kc4kwhr&t=1","data":"<!DOCT
⚡️  [warn] - [2023-04-22T14:51:52.422Z]  @firebase/firestore: Firestore (8.10.1): Connection WebChannel transport errored: [object Object]
⚡️  [error] - [2023-04-22T14:51:52.423Z]  @firebase/firestore: Firestore (8.10.1): Could not reach Cloud Firestore backend. Connection failed 1 times. Most recent error: FirebaseError: [code=unavailable]: The operation could not be completed
This typically indicates that your device does not have a healthy Internet connection at the moment. The client will operate in offline mode until it is able to successfully connect to the backend.
⚡️  To Native ->  CapacitorHttp request 62249784
2023-04-22 16:51:52.475173+0200 App[6009:63443] [NSURLSession sharedSession] may not be invalidated

I can see the "internet connection" suggestion in the error output there but that is not an issue.

I'd simply remove http but I believe I need it to get capacitor-community/background-geolocation working (to make http calls from the background)

mrtnrs commented 1 year ago

I have the same issue, but with Supabase Auth...

ionitron-bot[bot] commented 1 year ago

This issue needs more information before it can be addressed. In particular, the reporter needs to provide a minimal sample app that demonstrates the issue. If no sample app is provided within 15 days, the issue will be closed. Please see the Contributing Guide for how to create a Sample App. Thanks! Ionitron 💙

dallastjames commented 1 year ago

An alternative here if you're not needing to proxy all of the requests (which if you're using something like firebase or supabase you probably don't want to proxy everything), is just to only use Capacitor HTTP directly for the specific requests instead of enabling the proxy and patching fetch/xmlhttprequest https://capacitorjs.com/docs/apis/http#example

Ionitron commented 1 year ago

It looks like this issue didn't get the information it needed, so I'll close it for now. If I made a mistake, sorry! I am just a bot.

Have a great day! Ionitron 💙

ionitron-bot[bot] commented 11 months ago

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Capacitor, please create a new issue and ensure the template is fully filled out.