Skip to content

Specifying custom host for Data Connect emulator causes crash #8376

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
OutdatedGuy opened this issue Mar 27, 2025 · 7 comments
Open

Specifying custom host for Data Connect emulator causes crash #8376

OutdatedGuy opened this issue Mar 27, 2025 · 7 comments
Assignees
Labels
emulator: dataconnect Issues related to the dataconnect emulator type: bug

Comments

@OutdatedGuy
Copy link
Contributor

[REQUIRED] Environment info

firebase-tools: 14.0.0

Platform: macOS

[REQUIRED] Test case

N/A

[REQUIRED] Steps to reproduce

  1. Create a firebase project with Data Connect using:

    firebase init dataconnect
  2. Update the firebase.json file to configure port and host:

    {
      "emulators": {
        "dataconnect": {
          "dataDir": "dataconnect/.dataconnect/pgliteData",
          "port": 9399,
          "host": "192.168.1.2" // <- change this to your local IP
        }
      }
    }
  3. Start the emulator with:

    firebase emulators:start --only dataconnect
  4. See the error:

     i  emulators: Starting emulators: dataconnect
     i  dataconnect: downloading dataconnect-emulator-2.0.0...
     Progress: ===============================================================================================> (100% of 27MB)
     i  dataconnect: Removing outdated emulator files: dataconnect-emulator-1.8.5
     i  dataconnect: Data Connect Emulator logging to dataconnect-debug.log
     i  dataconnect: Started up Postgres server, listening on {"address":"192.168.1.2","family":"IPv4","port":5432}
     i  emulators: Shutting down emulators.
     i  dataconnect: Stopping Data Connect Emulator
     ⚠  Data Connect Emulator has exited upon receiving signal: SIGINT
    
     Error: Data Connect emulator: undefined

[REQUIRED] Expected behavior

The Data Connect emulator should start successfully without any errors on the specified host and port.

[REQUIRED] Actual behavior

Emulator fails to start when custom (local IP) host is specified in firebase.json.

Additional Info

dataconnect-debug.log
I0327 23:52:07.432635    2723 load.go:37] Reloading schema and connectors...
I0327 23:52:07.465153    2723 control.go:71] [/emulator/dataconnect 9059] UpdateResources(): done
Schema: sources: schema/schema.gql [2088B] 
Connector "default": sources: connector/mutations.gql [1233B] connector/queries.gql [1802B] 
I0327 23:52:07.489910    2723 collector.go:107] schema extensions wrote into ".../dataconnect/.dataconnect/schema"
Generated sources: prelude.gql [67159B] 
I0327 23:52:07.490551    2723 load.go:115] Finished reloading
I0327 23:52:07.494261    2723 dev.go:95] Listening on address (HTTP + gRPC): 192.168.1.2:9399
@aalej aalej added the emulator: dataconnect Issues related to the dataconnect emulator label Mar 27, 2025
@aalej
Copy link
Contributor

aalej commented Mar 28, 2025

Hey @OutdatedGuy, thanks for the report. Discussed this with our engineering team and our initial guess is that this might be a port forwarding issue. Could you try setting emulators.dataconnect.host to 0.0.0.0 to see if you'd be able to start the emulators and successfully make a request to the Data Connect emulator? The firebase.json would look somewhat like

{
  "emulators": {
    "dataconnect": {
      "dataDir": "dataconnect/.dataconnect/pgliteData",
      "port": 9399,
      "host": "0.0.0.0"
    },
    ...
  },
  "dataconnect": {
    "source": "dataconnect"
  }
}

Also, I think we should improve that error message to give information on what error occurred.

@OutdatedGuy
Copy link
Contributor Author

@aalej setting host to 0.0.0.0 works as the emulator is running without crashing and I can run queries using the VS Code Firebase Data Connect extension.

@joehan
Copy link
Contributor

joehan commented Apr 1, 2025

@OutdatedGuy Glad to hear that you've found a working solution here - for anyone else running into this, using 0.0.0.0 will most likely fix your problem. However, I did some digging into the root cause here:

On my machine, when I point at my local private IP, I get a 503 from /emulator/configure withe the following message: transport: authentication handshake failed: local credentials rejected connection to non-local address

This message is coming from the grpc library that the Data Connect emulator uses - it does not recognize the private IP as a local address, so it rejects local (fake) credentials. I believe this is actually WAI, since that IP is accessible by other machines in your network. Because of this, we won't be able to support setting host to 192.168.x.x - however, we should definitely have a better error message here tho.

@joehan joehan closed this as completed Apr 1, 2025
@OutdatedGuy
Copy link
Contributor Author

I believe this is actually WAI, since that IP is accessible by other machines in your network.

@joehan but all the other emulators support setting local IP as host, wouldn't it make sense for Data Connect to also support it?

Also I don't want to accept connections from all devices from my network to all of my assigned IP addresses. Just the one I would set.

@joehan joehan reopened this Apr 2, 2025
@joehan
Copy link
Contributor

joehan commented Apr 2, 2025

Thinking about this more, we probably could just not use this host for communication between the data connect emulator and PGlite - that would circumvent the auth issues and still let you connect your app over 192.168.x.x.

Reopening this issue.

@Hiraqui
Copy link

Hiraqui commented Apr 7, 2025

Hi, I'm having the same issue when trying to update firebase-tools from v 13.35.1 to any newer one. I tried the latest today (14.1.0) and had the same outcome, so I had to rollback to 13.35.1 again.
I usually run it without any host property at all, but I tried the 0.0.0.0 trick and it does not work either and the logs are not showing any useful info:

i  emulators: Starting emulators: auth, functions, firestore, database, hosting, storage, dataconnect, extensions
!  hosting: The hosting emulator is configured but there is no hosting configuration. Have you run firebase init hosting?
!  functions: The following emulators are not running, calls to these services from the Functions emulator will affect production: apphosting, hosting, pubsub
i  firestore: Firestore Emulator logging to firestore-debug.log
+  firestore: Firestore Emulator UI websocket is running on 9150.
!  database: Did not find a Realtime Database rules file specified in a firebase.json config file. The emulator will default to allowing all reads and writes. Learn more about this option: https://firebase.google.com/docs/emulator-suite/install_and_configure#security_rules_configuration.
i  database: Database Emulator logging to database-debug.log
i  dataconnect: Data Connect Emulator logging to dataconnect-debug.log
i  dataconnect: Started up Postgres server, listening on {"address":"0.0.0.0","family":"IPv4","port":5432}
i  emulators: Shutting down emulators.
i  extensions: Stopping Extensions Emulator
i  functions: Stopping Functions Emulator
i  database: Stopping Database Emulator
!  Database Emulator has exited upon receiving signal: SIGKILL
i  firestore: Stopping Firestore Emulator
!  Firestore Emulator has exited upon receiving signal: SIGKILL
i  auth: Stopping Authentication Emulator
i  eventarc: Stopping Eventarc Emulator
i  dataconnect: Stopping Data Connect Emulator
!  Data Connect Emulator has exited upon receiving signal: SIGKILL
i  tasks: Stopping Cloud Tasks Emulator
i  hub: Stopping emulator hub

Error: Data Connect emulator: undefined

Having trouble? Try firebase [command] --help
18:10:47.543 [NamespaceSystem-akka.actor.default-dispatcher-5] INFO akka.event.slf4j.Slf4jLogger - Slf4jLogger started
18:10:47.875 [main] INFO com.firebase.server.forge.App$ - Listening at 127.0.0.1:9000

NOTE: I'm on Windows

@joehan joehan self-assigned this Apr 8, 2025
@Hiraqui
Copy link

Hiraqui commented Apr 25, 2025

Version 14.2.1 is having the same issue

Logs:

I0425 15:11:28.318946   13108 load.go:37] Reloading schema and connectors...
I0425 15:11:28.506778   13108 control.go:73] [/emulator/tool-data-connect eb22] UpdateResources(): done
Schema: sources: schema\schema.gql [3990B] 
Connector "tool-connector": sources: tool-connector\queries.gql [5693B] tool-connector\***.gql [646B] tool-connector\mutations.gql [1877B] 
Connector "functions-connector": sources: functions-connector\mutations.gql [2431B] functions-connector\queries.gql [397B] 
Connector "migrations-connector": sources: migrations-connector\mutations.gql [50630B] 
I0425 15:11:28.639142   13108 codegen.go:82] [connector "tool-connector" javascriptSdk] Generating sources into "***\\tool\\src\\lib\\firebase\\dataconnect-sdk"
I0425 15:11:28.648166   13108 codegen.go:82] [connector "functions-connector" javascriptSdk] Generating sources into "***\\tool\\functions\\src\\lib\\dataconnect-sdk"
I0425 15:11:28.657781   13108 collector.go:107] schema extensions wrote into "***\\tool\\dataconnect\\.dataconnect\\schema"
Generated sources: prelude.gql [71117B] main\mutation.gql [100314B] main\implicit.gql [11422B] main\input.gql [187996B] main\relation.gql [105358B] main\query.gql [36849B] 
I0425 15:11:28.660386   13108 collector.go:107] connector "tool-connector" javascriptSdk wrote into "***\\tool\\src\\lib\\firebase\\dataconnect-sdk"
Generated sources: esm\package.json [17B] index.cjs.js [5156B] package.json [652B] README.md [50823B] index.d.ts [14663B] esm\index.esm.js [4404B] 
I0425 15:11:28.695306   13108 installsdk.go:80] Running command: C:\Users\tincho\AppData\Local\pnpm\pnpm.cmd link src\lib\firebase\dataconnect-sdk

It also is creating unwanted dependencies in the package.json

    "dataconnect-sdk": "link:../../***/AppData/Local/pnpm/global/5/node_modules/src/lib/firebase/dataconnect-sdk",

...
    "overrides": {
      "@tool/dataconnect": "link:src\\lib\\firebase\\dataconnect-sdk",
      "dataconnect-sdk": "link:../../***/AppData/Local/pnpm/global/5/node_modules/src/lib/firebase/dataconnect-sdk"
    }


I have to keep rolling back to version 13.35.1 to make it work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
emulator: dataconnect Issues related to the dataconnect emulator type: bug
Projects
None yet
Development

No branches or pull requests

4 participants