Skip to content
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

Firebase error writing object from Firebase Storage to Firestore: Cloud function fails or doesn't continue and then fails eventually #662

Closed
maakle opened this issue Apr 18, 2020 · 4 comments

Comments

@maakle
Copy link

maakle commented Apr 18, 2020

Related issues

[REQUIRED] Version info

node::
v13.10.1 (local machine)

firebase-functions:
"firebase-functions": "^3.6.0"

firebase-tools:

firebase-admin:
"firebase-admin": "^8.10.0"

[REQUIRED] Steps to reproduce

My cloud function isn't able to write to the database. When I run it on my local machine I am able to write the objects to Firestore. But when I run the cloud function, it correctly processes the CSV until the moment where I try to wrote it to the database. My Code:

const saveObjectToFirestore = (objects: Array<any>, datatype: string) => {
  for (let obj of objects) {
    const slug = helpermethods.createDatatypeSlug(obj, datatype);
    const folder = helpermethods.createDestinationFolder(datatype);

    // Converts string date to firebase date
    const objectWithDate = helpermethods.convertToDateObject(obj, datatype);
    console.log(objectWithDate)

    db.collection("crawlerdata")
      .doc(datatype)
      .collection(folder)
      .doc(slug)
      .set(objectWithDate)
      .then(function () {
        console.log(`New object created at: ${datatype}/${folder}/${slug}`);
      })
      .catch(function (error: any) {
        console.error(`Error writing object: ${datatype}/${folder}/${slug}`);
        console.error("Details: ", error);
      });
  }
};

[REQUIRED] Expected behavior

It should write the objectWithDate to Firestore.

[REQUIRED] Actual behavior

The Cloud function doesn't continue or stop. It then fails after some time with this output:

extractCrawledDataToFirestore
Error writing object: crunchbase/transactions/stripe-series-g--cdb058e0 

It Logs Viewer the details are:

 {
 insertId: "000000-aab29feb-db9d-4865-a81b-03c4b7884fed"  
 
labels: {…}  
 logName: "projects/leadsource-e5086/logs/cloudfunctions.googleapis.com%2Fcloud-functions"  
 receiveTimestamp: "2020-04-18T22:32:35.278763097Z"  
 
resource: {…}  
 severity: "ERROR"  
 textPayload: "Error writing object: crunchbase/transactions/stripe-series-g--cdb058e0"  
 timestamp: "2020-04-18T22:32:24.811Z"  
 trace: "projects/leadsource-e5086/traces/c035b074e2cdfa8c5e895c1ed0c4c6df"  
}

Were you able to successfully deploy your functions?

Yes, I am able to deploy the function. Funnily if I do the same thing for a JSON, it works. But here only for exporting a CSV it doesn't.
I also got this error here sometimes related. Sometimes also no error shows up and it is just stuck forever and doesn't finish.

Screen Shot 2020-04-18 at 5 51 25 PM

Before that also it sometimes timed out:

2020-04-18 15:12:04.313 PDT
extractCrawledDataToFirestore
1135009007131339
Details: { Error: 14 UNAVAILABLE: No connection established at Object.callErrorFromStatus (/srv/node_modules/@grpc/grpc-js/build/src/call.js:30:26) at Object.onReceiveStatus (/srv/node_modules/@grpc/grpc-js/build/src/client.js:174:52) at Object.onReceiveStatus (/srv/node_modules/@grpc/grpc-js/build/src/client-interceptors.js:340:141) at Object.onReceiveStatus (/srv/node_modules/@grpc/grpc-js/build/src/client-interceptors.js:303:181) at Http2CallStream.outputStatus (/srv/node_modules/@grpc/grpc-js/build/src/call-stream.js:114:27) at Http2CallStream.maybeOutputStatus (/srv/node_modules/@grpc/grpc-js/build/src/call-stream.js:153:22) at Http2CallStream.endCall (/srv/node_modules/@grpc/grpc-js/build/src/call-stream.js:140:18) at Http2CallStream.cancelWithStatus (/srv/node_modules/@grpc/grpc-js/build/src/call-stream.js:441:14) at ChannelImplementation.tryPick (/srv/node_modules/@grpc/grpc-js/build/src/channel.js:214:32) at Object.updateState (/srv/node_modules/@grpc/grpc-js/build/src/channel.js:82:26) code: 14, details: 'No connection established', metadata: Metadata { internalRepr: Map {}, options: {} } }
Expand all | Collapse all
{
 insertId: "000002-bc1fa649-2e31-43d7-8a28-2614ffc8efed"  
 
labels: {…}  
 logName: "projects/leadsource-e5086/logs/cloudfunctions.googleapis.com%2Fcloud-functions"  
 receiveTimestamp: "2020-04-18T22:12:10.199384682Z"  
 
resource: {…}  
 severity: "ERROR"  
 textPayload: "Details:  { Error: 14 UNAVAILABLE: No connection established
    at Object.callErrorFromStatus (/srv/node_modules/@grpc/grpc-js/build/src/call.js:30:26)
    at Object.onReceiveStatus (/srv/node_modules/@grpc/grpc-js/build/src/client.js:174:52)
    at Object.onReceiveStatus (/srv/node_modules/@grpc/grpc-js/build/src/client-interceptors.js:340:141)
    at Object.onReceiveStatus (/srv/node_modules/@grpc/grpc-js/build/src/client-interceptors.js:303:181)
    at Http2CallStream.outputStatus (/srv/node_modules/@grpc/grpc-js/build/src/call-stream.js:114:27)
    at Http2CallStream.maybeOutputStatus (/srv/node_modules/@grpc/grpc-js/build/src/call-stream.js:153:22)
    at Http2CallStream.endCall (/srv/node_modules/@grpc/grpc-js/build/src/call-stream.js:140:18)
    at Http2CallStream.cancelWithStatus (/srv/node_modules/@grpc/grpc-js/build/src/call-stream.js:441:14)
    at ChannelImplementation.tryPick (/srv/node_modules/@grpc/grpc-js/build/src/channel.js:214:32)
    at Object.updateState (/srv/node_modules/@grpc/grpc-js/build/src/channel.js:82:26)
  code: 14,
  details: 'No connection established',
  metadata: Metadata { internalRepr: Map {}, options: {} } }"  
 timestamp: "2020-04-18T22:12:04.313Z"  
 trace: "projects/leadsource-e5086/traces/e61aed435bc0fee717254f506f00e605"  
}
@google-oss-bot
Copy link
Collaborator

I found a few problems with this issue:

  • I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.
  • This issue does not seem to follow the issue template. Make sure you provide all the required information.

@joehan
Copy link
Contributor

joehan commented Apr 21, 2020

Hey @mattk90, sorry to hear that you're having this issue. This looks to be very similar to #568 - the underlying issue there looked to be a version disagreement related to '@grpc/grpc-js'. Could you check your package-lock.json, and make sure that any references to @grpc/grpc-js" are up to date?

@laurenzlong laurenzlong added Needs: Author Feedback Issues awaiting author feedback and removed needs-triage labels May 28, 2020
@google-oss-bot
Copy link
Collaborator

Hey @mattk90. We need more information to resolve this issue but there hasn't been an update in 7 weekdays. I'm marking the issue as stale and if there are no new updates in the next 3 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!

@google-oss-bot
Copy link
Collaborator

Since there haven't been any recent updates here, I am going to close this issue.

@mattk90 if you're still experiencing this problem and want to continue the discussion just leave a comment here and we are happy to re-open this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants