-
Notifications
You must be signed in to change notification settings - Fork 1k
Unable to perform queries on Data Connect
locally using Cloud Functions
in emulator
#8379
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
Comments
Data Connect
locally using Cloud Functions
in emulator
Thanks for sharing a test case @OutdatedGuy! When trying to reproduce this issue, I noticed that the debug logs indicate that a request is being made to production instead of the Data Connect emulator, which could be causing the error. Did you notice any logs similar to below?
If you are trying to make a query on the Data Connect emulator, could you try updating your code to something like: import { initializeApp } from "firebase-admin/app";
import { getDataConnect } from "firebase-admin/data-connect";
import { onRequest } from "firebase-functions/https";
process.env.DATA_CONNECT_EMULATOR_HOST = "127.0.0.1:9399"; // Connects to the Data Connect emulator
initializeApp();
export const callFn = onRequest(async (_req, res) => {
const dataConnect = getDataConnect({
location: "us-central1",
serviceId: "test-dc-2",
});
const result = await dataConnect.executeGraphql(
`mutation {
movie_insert(
data: {
id: "11111111222233334444555555555667"
genre: ""
imageUrl: ""
title: ""
}
)
}
`
);
res.status(200).json({ result });
}); The Firebase CLI should be automatically setting Data Connect emulator host when it detects that the Data Connect emulator is being used. If you are trying to connect to a production instance of Data Connect, could you double check if your |
Yes, I can see the accessing production service warning.
process.env.DATA_CONNECT_EMULATOR_HOST = "127.0.0.1:9399"; Adding the above line worked in my main codebase (hurray 🎉), but I'm getting the below error in my demo (Minimum Reproducible Code). ⚠ functions: Error: Error while making request: write EPROTO 4008DDEB01000000:error:0A00010B:SSL routines:ssl3_get_record:wrong version number:../deps/openssl/openssl/ssl/record/ssl3_record.c:355:
. Error code: EPROTO
at .../functions/node_modules/firebase-admin/lib/utils/api-request.js:265:19
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
at async .../functions/node_modules/firebase-admin/lib/data-connect/data-connect-api-client-internal.js:91:26
at async .../functions/lib/index.js:14:20
at async runFunction (/usr/local/lib/node_modules/firebase-tools/lib/emulator/functionsEmulatorRuntime.js:506:9)
at async runHTTPS (/usr/local/lib/node_modules/firebase-tools/lib/emulator/functionsEmulatorRuntime.js:531:5)
at async /usr/local/lib/node_modules/firebase-tools/lib/emulator/functionsEmulatorRuntime.js:694:21
⚠ Your function was killed because it raised an unhandled error.
i Request to function failed: Error: socket hang up Thanks @aalej for the help! |
@aalej @joehan after updating ⚠ functions: Error: Error while making request: getaddrinfo ENOTFOUND http. Error code: ENOTFOUND So playing around a bit with host values I figured out that setting So it looks like this change from #8387 needs to be modified. |
[REQUIRED] Environment info
firebase-tools: 14.0.0
Platform: macOS
[REQUIRED] Test case
index.ts
schema.gql
[REQUIRED] Steps to reproduce
Create a firebase project with
Data Connect
&Cloud Functions
in Typescript using:Update the
functions/src/index.ts
file with the code above.Update the
dataconnect/schema/schema.gql
file with the schema above.Run below command to install latest dependencies:
Run emulator using the command below:
npm run build && firebase emulators:start
Call the http function using the command below:
Check the error logs in the console.
[REQUIRED] Expected behavior
When running locally using emulators, the function should execute successfully and insert a new movie record into the Data Connect table.
[REQUIRED] Actual behavior
The text was updated successfully, but these errors were encountered: