-
Notifications
You must be signed in to change notification settings - Fork 928
httpsCallable keeps open a timer even after responses are received #2746
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
I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight. |
Are you sure that
Results:
The If |
Hey @minism. We need more information to resolve this issue but there hasn't been an update in 5 weekdays. I'm marking the issue as stale and if there are no new updates in the next 5 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! |
Thanks for the response @hsubox76 , sorry for the delay!
In fact, the bug is present even if the function you're trying to call does not exist.
The issue is not with Promise.race, that is working as expected. The httpsCallable function call immediately returns, that specific call doesn't hang. The issue is that My suggestion is that the library code should delete the timer using clearTimeout when it knows it will no longer wait for the callback -- the timer serves no purpose at that point.
I probably didn't describe it well initially -- fn() resolves just fine. The problem is the lingering timer created by it. |
That makes sense, but I'm having no luck trying to reproduce it. I created a simple project that only runs a Jest test, like this:
Then I run Jest from the command line:
I also tried to call an invalid function name and it also finishes (with an error) in about 4s. Is there something I can change to get the results you're seeing? |
Hey @minism. We need more information to resolve this issue but there hasn't been an update in 5 weekdays. I'm marking the issue as stale and if there are no new updates in the next 5 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! |
Hey @minism. We need more information to resolve this issue but there hasn't been an update in 5 weekdays. I'm marking the issue as stale and if there are no new updates in the next 5 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! |
Since there haven't been any recent updates here, I am going to close this issue. @minism 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. |
@hsubox76 Interesting, it is possible we are on different node versions as well. I created a repository that contains the minimal code to reproduce the issue, it just tries to call a function that doesnt exist, inside of an async function: https://github.com/minism/firebase-timeout-repro Run it with:
Observe the javascript time log showing the request returns quickly, however (at least on my machine), the process stays open for another 70 seconds before returning to the shell. I can repro this with both node v8.17.0 and node v10.19.0, both on OSX. |
[REQUIRED] Describe your environment
[REQUIRED] Describe the problem
httpsCallable keeps open a timer even after responses are received, due to this line here:
firebase-js-sdk/packages/functions/src/api/service.ts
Line 218 in ae31905
This causes undesirable behavior when utilizing the SDK in short run process, for example in integration tests. An immediate response from the cloud API will still cause the node process to stay alive for
timeout
milliseconds, due to this timer.Instead, the SDK should be smart enough to cancel the unnecessary timer as soon as a response is received.
Steps to reproduce:
Example jest unit test:
Expectation: Test should finish in under 10 seconds.
Actual: Test waits for 70 seconds before terminating.
The open timer can be seen using the
wtfnode
package:console.log node_modules/wtfnode/index.js:53
- Timers:
console.log node_modules/wtfnode/index.js:53
- (70000 ~ 1 min) (anonymous) @ ./node_modules/firebase/node_modules/@firebase/functions/dist/index.node.cjs.js:373
https://stackblitz.com/fork/firebase-issue-sandbox
// TODO(you): code here to reproduce the problem
The text was updated successfully, but these errors were encountered: