You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In Firebase console -> Functions select your_callable_function and open the Detailed usage stats using the 3 dot menu.
This will open the Google Cloud Console -> Function details page for the function.
Select the Logs tab and wait for the logs to load.
Check how many times the function was called when you refreshed the browser page.
Expected behavior
The function should be called once.
202x-xx-xx xx:xx:xx.731 xxx | POST 200 xxx B x ms xxxxxx https://region-project.cloudfunctions.net/your_callable_function
Actual behavior
The function is actually called twice.
202x-xx-xx xx:xx:xx.731 xxx | POST 200 xxx B x ms xxxxxx https://region-project.cloudfunctions.net/your_callable_function
202x-xx-xx xx:xx:xx.798 xxx | POST 200 xxx B x ms xxxxxx https://region-project.cloudfunctions.net/your_callable_function
Workaround
Using the httpsCallable from firebase/functions combined with the native hooks useEffect and useState solves the issue.
Short description
Using the
useCallableFunctionResponse
hook fromreactfire
causes the function to be called twice.This might lead to undesired costs.
Version info
React: "^18"
Firebase: "^10.0.0"
ReactFire: "^4.2.3"
Next: "14.1.0"
Node: "^20"
Test case
Content of
app/layout.tsx
:Content of
app/page.tsx
:Content of
app/test.tsx
:Steps to reproduce
npm run dev
)Firebase console
->Functions
selectyour_callable_function
and open theDetailed usage stats
using the 3 dot menu.This will open the
Google Cloud Console
->Function details
page for the function.Logs
tab and wait for the logs to load.Expected behavior
The function should be called once.
Actual behavior
The function is actually called twice.
Workaround
Using the
httpsCallable
fromfirebase/functions
combined with the native hooksuseEffect
anduseState
solves the issue.Content of
app/test.tsx
:The text was updated successfully, but these errors were encountered: