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

Callable Function throw Deadline Exceeded Error even on successful response #3289

Closed
stevecastaneda opened this issue Jun 25, 2020 · 12 comments · Fixed by #3330
Closed

Callable Function throw Deadline Exceeded Error even on successful response #3289

stevecastaneda opened this issue Jun 25, 2020 · 12 comments · Fixed by #3330
Assignees

Comments

@stevecastaneda
Copy link

stevecastaneda commented Jun 25, 2020

[REQUIRED] Describe your environment

  • Operating System version: MacOS Catalina 10.15.5
  • Browser version: Chrome 83.0.4103.116
  • Firebase SDK version: 7.15.5
  • Firebase Product: Functions
  • Issue persists with Node 12.18.1 and 14.4.0

[REQUIRED] Describe the problem

Steps to reproduce:

This is a continuation from issue #2746, and I'm experiencing the same deadline-exceeded error even after Promise.race successfully returns a promise (as evidenced by the callable function returning data as I expect).

@minism

Function Relevant Code: [Typescript]

import * as functions from "firebase-functions";
import * as admin from "firebase-admin";
admin.initializeApp();

export const helloUser = functions.https.onCall((data, context) => {
  if (context.auth) {
    return { response: "There's a user!", data };
  } else {
    throw new functions.https.HttpsError("permission-denied", "You must be logged in.");
  }
});

Frontend (React)

async function testFunction() {
  try {
        let functionTest = functions.httpsCallable("helloUser");
        let response = await functionTest();
        console.log(response);
      } catch (error) {
        console.log(error);
      }
}
@google-oss-bot
Copy link
Contributor

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

@stevecastaneda
Copy link
Author

For reference, could this be a proposed solution so that the timer is cleared when Promise.race is satisfied?

https://stackoverflow.com/questions/30936824/what-is-the-best-general-practice-to-timeout-a-function-in-promise

export function race({promise, timeout, error}) {
  let timer = null;

  return Promise.race([
    new Promise((resolve, reject) => {
      timer = setTimeout(reject, timeout, error);
      return timer;
    }),
    promise.then((value) => {
      clearTimeout(timer);
      return value;
    })
  ]);
}

@Feiyang1 Feiyang1 self-assigned this Jun 26, 2020
@Feiyang1
Copy link
Member

@stevecastaneda issue #2746 mentions the issue only manifests in Node. Is your issue also happening in Nodejs (server rendering)? Just want to clarify because you include React code, also that I can't reproduce it in browser.

@stevecastaneda
Copy link
Author

stevecastaneda commented Jun 26, 2020

@Feiyang1 Thanks for looking at this for me.

I'm running React locally along with emulated firebase functions. Interestingly enough, I just noticed that after deploying the site to a host along with functions to Firebase, I don't get the error anymore. (the deployed site is using firebase functions vs. local emulated functions, same code though).

So perhaps this is isolated to running a local build of React?

I could possibly reproduce if we start a new project at Firebase, connect it to a fresh install of React, emulate a simple function locally. I'm just not 100% sure how I'd share that if the project is built on my Google login.

Another thought is that maybe it could be an emulated function and not react. I'm going to try using the deployed function instead to see if the locally running React build throws the error...

@stevecastaneda
Copy link
Author

stevecastaneda commented Jun 26, 2020

Using the deployed function still threw the error, so it looks like the culprit is the local build of React that I'm running. This is create-react-app with Typescript. I start the server using react-scripts start.

@stevecastaneda
Copy link
Author

Nevermind. It's also happening on the deployed site, unfortunately. Tested by adding a 10-second timeout to the callable function (that did return well before that).

Any recommendations on how I can help diagnose this issue?

@Feiyang1
Copy link
Member

Would you mind sharing the deployed site?

@minism
Copy link

minism commented Jun 26, 2020

@Feiyang1 I have a repro for the bug at the end of #2746. I was hoping my comment would reopen the bug but unfortunately it didn't.

@stevecastaneda
Copy link
Author

@minism Thanks!

@Feiyang1 If you can't reproduce there, let me know and I can create a new CRA site and deploy it for testing.

@stevecastaneda
Copy link
Author

I'm able to trigger this error even with the simplest of callable functions. Here's an example:

https://gist.github.com/stevecastaneda/7c07f91ce1eeef005175071efda39401

@Feiyang1
Copy link
Member

Feiyang1 commented Jul 1, 2020

#3330 should resolve the issue.

@stevecastaneda
Copy link
Author

@Feiyang1 Thank you!

@firebase firebase locked and limited conversation to collaborators Aug 7, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants