firebase-functions icon indicating copy to clipboard operation
firebase-functions copied to clipboard

Realtime instance can not be configured using params for onValueWritten functions

Open pitazzo opened this issue 1 year ago • 1 comments

Version info

node: v20.10.0

firebase-functions: ^5.1.1

firebase-tools: 13.16.0

firebase-admin: ^12.4.0

Test case

Setup a Firebase Cloud Function with the following code:

exports.foo = onValueWritten(
  {
    ref: '/foo/bar,
    instance: defineString('REALTIME_INSTANCE'),
  },
  async (change) => {
    console.log('hey!);
  },
);

Steps to reproduce

Try to compile following the example code, npm run build.

Expected behavior

We should be able to deploy functions with Realtime instance as a parameter. This is very needed in projects with different Realtime instance per environment. For example, we have to different Realtime instances, one for production and another for staging, and we want to have our functions deployed twice, once per instance.

Actual behavior

As the ReferenceOptions<Ref> object only accepts string as type for the instance value, it's impossible to configure it based on the environment.

Were you able to successfully deploy your functions?

No, as it's impossible to build the codebase.

pitazzo avatar Sep 11 '24 09:09 pitazzo