Skip to content

Scheduled functions can no longer be triggered from functions:shell (after upgrading from v11.9.0 to v11.16.1) #5259

@johnnyoshika

Description

@johnnyoshika

[REQUIRED] Environment info

firebase-tools: 11.16.1

Platform: Windows and macOS

[REQUIRED] Test case

Create a scheduled function:

export const triggerSomething = functions
  .region('us-central1')
  .runWith({
    timeoutSeconds: 300,
    memory: '1GB',
  })
  .pubsub.schedule('every 5 minutes')
  .onRun(async () => {
    console.log('Triggered!');
    return null;
  });

[REQUIRED] Steps to reproduce

Start the emulator:

firebase emulators:start --project demo-project --inspect-functions --only auth,functions,firestore,storage --import exports/seed

Start functions:shell

firebase functions:shell --project demo-project

Now trigger the scheduled function inside functions:shell:

firebase > triggerSomething()

[REQUIRED] Expected behavior

Version 11.9.0

In firebase-tools version 11.9.0, it worked as expected. This was the output from firebase functions:shell --project demo-project

!  functions: You are already running the Cloud Functions emulator on port 5001. Running the emulator and the Functions shell simultaenously can result in unexpected behavior.
!  functions: package.json indicates an outdated version of firebase-functions. Please upgrade using npm install --save firebase-functions@latest in your functions directory.
!  functions: Please note that there will be breaking changes when you upgrade.
i  functions: Loaded functions: {redacted, but it would include triggerSomething}
i  functions: Connected to running firestore emulator at localhost:8080, calls to this service will affect the emulator
i  functions: Connected to running eventarc emulator at localhost:9299, calls to this service will affect the emulator
!  functions: The following emulators are not running, calls to these services will affect production: database, pubsub, storage

Now running this command:

firebase > triggerSomething()

was successful:

'Successfully invoked function.'
firebase > !  functions: The Firebase Storage emulator is not running, so calls to Firebase Storage will affect production.
>  Triggered!

[REQUIRED] Actual behavior

Version 11.16.1

In firebase-tools version 11.16.1, this stopped working. This is the output from firebase functions:shell --project demo-project

!  functions: You are already running the Cloud Functions emulator on port 5001. Running the emulator and the Functions shell simultaenously can result in unexpected behavior.
!  functions: package.json indicates an outdated version of firebase-functions. Please upgrade using npm install --save firebase-functions@latest in your functions directory.
!  functions: Please note that there will be breaking changes when you upgrade.
i  functions: Loaded functions: {redacted, but it would include triggerSomething}
i  functions: Connected to running firestore emulator at 127.0.0.1:8080, calls to this service will affect the emulator
i  functions: Connected to running storage emulator at 127.0.0.1:9199, calls to this service will affect the emulator
i  functions: Connected to running eventarc emulator at 127.0.0.1:9299, calls to this service will affect the emulator
!  functions: The following emulators are not running, calls to these services will affect production: database, pubsub

Now running this command:

firebase > triggerSomething()

failed:

'Successfully invoked function.'
firebase > !  functions: The Cloud Firestore emulator is not running, so calls to Firestore will affect production.
!  functions: The Firebase Storage emulator is not running, so calls to Firebase Storage will affect production.
!  Google API requested!
   - URL: "https://oauth2.googleapis.com/token"
   - Be careful, this may be a production service.
!  functions: Error: 7 PERMISSION_DENIED: Cloud Firestore API has not been used in project {redacted} before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/firestore.googleapis.com/overview?project={redacted} then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.
    at Object.callErrorFromStatus ({redacted}\node_modules\@grpc\grpc-js\build\src\call.js:31:26)
    at Object.onReceiveStatus ({redacted}\node_modules\@grpc\grpc-js\build\src\client.js:331:49)
    at Object.onReceiveStatus ({redacted}\node_modules\@grpc\grpc-js\build\src\client-interceptors.js:328:181)
    at {redacted}\node_modules\@grpc\grpc-js\build\src\call-stream.js:182:78
    at processTicksAndRejections (node:internal/process/task_queues:78:11)
Caused by: Error
    at Query._get ({redacted}\node_modules\@google-cloud\firestore\build\src\reference.js:1519:23)
    at Query.get ({redacted}\node_modules\@google-cloud\firestore\build\src\reference.js:1507:21)
    at {redacted}\fbase\functions\lib\schedules\triggerGenerateAttemptResults.js:27:10
    at cloudFunction ({redacted}\fbase\functions\node_modules\firebase-functions\lib\cloud-functions.js:131:23)
    at C:\Users\{redacted}\AppData\Roaming\nvm\v16.13.2\node_modules\firebase-tools\lib\emulator\functionsEmulatorRuntime.js:516:16
    at runFunction (C:\Users\{redacted}\AppData\Roaming\nvm\v16.13.2\node_modules\firebase-tools\lib\emulator\functionsEmulatorRuntime.js:504:15)
    at runBackground (C:\Users\{redacted}\AppData\Roaming\nvm\v16.13.2\node_modules\firebase-tools\lib\emulator\functionsEmulatorRuntime.js:515:11)
    at processBackground (C:\Users\{redacted}\AppData\Roaming\nvm\v16.13.2\node_modules\firebase-tools\lib\emulator\functionsEmulatorRuntime.js:499:11)
    at C:\Users\{redacted}\AppData\Roaming\nvm\v16.13.2\node_modules\firebase-tools\lib\emulator\functionsEmulatorRuntime.js:690:27
    at Layer.handle [as handle_request] (C:\Users\{redacted}\AppData\Roaming\nvm\v16.13.2\node_modules\firebase-tools\node_modules\express\lib\router\layer.js:95:5)
!  Your function was killed because it raised an unhandled error.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions