extensions icon indicating copy to clipboard operation
extensions copied to clipboard

storage-resize-images "functions: Cannot find module 'object-assign'"

Open linxydmhg opened this issue 3 years ago • 0 comments

  • Extension name: storage-resize-images
  • Extension version: 0.1.29
  • Configuration values (redact info where appropriate):
ALLOWED_EVENT_TYPES=firebase.extensions.storage-resize-images.v1.complete
DELETE_ORIGINAL_FILE=false
EVENTARC_CHANNEL=projects/${param:PROJECT_ID}/locations/us-central1/channels/firebase
FUNCTION_MEMORY=1024
IMAGE_TYPE=jpeg
IMG_BUCKET=projectname.appspot.com
IMG_SIZES=300x300
IS_ANIMATED=true
LOCATION=southamerica-east1
MAKE_PUBLIC=false

[REQUIRED] Step 3: Describe the problem

With firebase-admin, firebase-functions, and tools, all at the latest version, the extension does not trigger within the emulator, but it fails instead.

Steps to reproduce:

Create and initialize firebase to the latest version, call firebase init and create a new functions folder. Then enable the emulator, and extensions, and then put this into index.ts

import { onCustomEventPublished } from "firebase-functions/v2/eventarc";
      
export const eventhandler = onCustomEventPublished(
    "firebase.extensions.storage-resize-images.v1.complete",
    (e) => {
        console.log('Extension triggered');
    });

And upload a image.

Expected result

Function trigger to work normally

Actual result
⚠  functions: Cannot find module 'object-assign'
Require stack:
- /Users/linxy/.cache/firebase/extensions/firebase/[email protected]/functions/node_modules/cors/lib/index.js
- /Users/linxy/.cache/firebase/extensions/firebase/[email protected]/functions/node_modules/firebase-functions/lib/common/providers/https.js
- /Users/linxy/.cache/firebase/extensions/firebase/[email protected]/functions/node_modules/firebase-functions/lib/common/providers/identity.js
- /Users/linxy/.cache/firebase/extensions/firebase/[email protected]/functions/node_modules/firebase-functions/lib/providers/auth.js
- /Users/linxy/.cache/firebase/extensions/firebase/[email protected]/functions/node_modules/firebase-functions/lib/index.js
- /usr/local/lib/node_modules/firebase-tools/lib/emulator/functionsEmulatorRuntime.js
⚠  Your function was killed because it raised an unhandled error.

Here is my pubspec, its newly made in a new firebase init: I added a dev dependency of object-assign, to see if it would work,it does not

{
  "name": "functions",
  "scripts": {
    "lint": "eslint --ext .js,.ts .",
    "build": "tsc",
    "build:watch": "tsc --watch",
    "serve": "npm run build && firebase emulators:start --only functions",
    "shell": "npm run build && firebase functions:shell",
    "start": "npm run shell",
    "deploy": "firebase deploy --only functions",
    "logs": "firebase functions:log"
  },
  "engines": {
    "node": "16"
  },
  "main": "lib/index.js",
  "dependencies": {
    "firebase-admin": "^11.0.1",
    "firebase-functions": "^3.22.0"
  },
  "devDependencies": {
    "@typescript-eslint/eslint-plugin": "^5.12.0",
    "@typescript-eslint/parser": "^5.12.0",
    "eslint": "^8.9.0",
    "eslint-config-google": "^0.14.0",
    "eslint-plugin-import": "^2.25.4",
    "firebase-functions-test": "^0.2.0",
    "object-assign": "^4.1.1",
    "typescript": "^4.5.4"
  },
  "private": true
}

linxydmhg avatar Aug 21 '22 20:08 linxydmhg