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

Local Function Emulator Triggering wrong function #4189

Closed
markdagraca opened this issue Feb 17, 2022 · 16 comments · Fixed by #4232
Closed

Local Function Emulator Triggering wrong function #4189

markdagraca opened this issue Feb 17, 2022 · 16 comments · Fixed by #4232
Assignees

Comments

@markdagraca
Copy link

Trying to run my react typescript project using Local Emulator and it is triggering the wrong function when called from the front end. Code is working perfectly in the production and test environment but not in Local

@markdagraca
Copy link
Author

Downgraded to 10.1.5 and it appears to be working properly but I'm now missing env variables features found in 10.2

@Albertbol
Copy link

exactly the same issue for the node js environment, all latest libraries

    "engines": {
        "node": "16"
    },
    "main": "dist/index.js",
    "dependencies": {
        "firebase": "^9.6.7",
        "firebase-admin": "^10.0.2",
        "firebase-functions": "^3.18.1"
    },

@roobd
Copy link

roobd commented Feb 20, 2022

I have the same issue that my function triggers are not working anymore after the upgrade to 10.2.1.
There is only one onCreate function triggered all the time, even a creation on a completely different document path is triggering this one function.

A downgrade to 10.2.0. does not fix the issue.

I use firebase-functions at version 3.18.1

A downgrade to 10.1.5 is fixing the issue and all triggers are working as expected again.

@taeold taeold self-assigned this Feb 22, 2022
@taeold
Copy link
Contributor

taeold commented Feb 22, 2022

We are taking a look at the issue. Sorry for the inconvenience!

@ggirotto
Copy link

We were facing the same issue but it stopped happening yesterday.

@gustavrannestig
Copy link

I have the same issue. From what I can see the patterin is that it seems to be stuck on the first called function.

So when I restart the emulators, I can choose what function to use for that "session" by firing that first. But then I can't switch and call another function without restarting.

So I'm guessing some sort of cache bug? :)

@haroldadmin
Copy link

Can confirm, facing the same issue that @gustavrannestig described. It keeps triggering the first triggered function for any subsequent API calls.

@taeold
Copy link
Contributor

taeold commented Feb 24, 2022

Been investigating the issue, and @gustavrannestig's description helps a ton. Will post an update here once I get a sense of the bug - apologies to everyone for the inconvenience.

@zebreus
Copy link

zebreus commented Feb 24, 2022

I also have the same issue. The first triggered function is called for any subsequent API calls.
The first bad firebase-tools version is 10.2.0.
The issue only happens, when the functions emulator is in debug mode.

@taeold
Copy link
Contributor

taeold commented Feb 24, 2022

@zebreus Thanks for a very helpful pointer.

Is everyone reporting the issue also starting the emulator with --inspect-functions flag?

@markdagraca
Copy link
Author

markdagraca commented Feb 24, 2022 via email

@markdagraca
Copy link
Author

markdagraca commented Feb 24, 2022

What @gustavrannestig said is exactly what I was experiencing

@taeold taeold modified the milestone: yuuiu7jnhh6uyyuum Feb 24, 2022
@gustavrannestig
Copy link

@taeold yes I'm also running the emulators with --inspect-functions

@nikgavalas
Copy link

I removed the --inspect-functions flag and everything seems to work just fine. If I add it in I can confirm that the issue occurs again. Hopefully that helps in tracking down the fix!

@doo-gl
Copy link

doo-gl commented Feb 28, 2022

Similar issue, starting the emulator, it will repeatedly run whatever was the initial function regardless of what path is used.

Downgrading to 10.1.5 resolves the issue for now.

For those looking for what to do, run:

npm install -g [email protected]

check your running version is 10.1.5 using

firebase --version

If it is still 10.2.x, restart your terminal.

taeold added a commit that referenced this issue Mar 2, 2022
…th --inspect-functions flag (#4232)

In #4149, we made large refactor of the Functions Runtime. Namely:

1) We no longer relied on Functions Runtime to parse triggers. Instead, we use [`RuntimeDelegate`](https://github.com/firebase/firebase-tools/blob/2a56d9520241ab9897a59aac22c9fd016251a7cd/src/deploy/functions/runtimes/index.ts#L114), the same procedure used to parse trigger in `firebase deploy` command.

2) Each process running the Functions Runtime was bound to a specific trigger.

Unfortunately, this change broke support for `--inspect-function` where users can attach Node Debugger to step through their function when triggered.

The debugging experience supported w/ `--inspect-function` relies on the fact that a single process executes all function triggers. This is drastically different to how functions run in Production environment, but it is a very useful feature that makes it easy to step through all functions in a single debug session.

I wasn't aware of the debugging capabilities when making the refactor. Unfortunately, the debug feature cuts across a strong assumption I've made for the future of Functions Emulator. This is a rather hasty rollback - I'm going to have to think more deeply about how we want the evolve this feature.

Fixes #4189, #4166
@taeold
Copy link
Contributor

taeold commented Mar 3, 2022

Hi folks. The patch for this issue was released today in firebase-tools v10.2.2. Please give it a spin and let us know if things are working expected.

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