Skip to content
This repository has been archived by the owner on May 15, 2019. It is now read-only.

NotFoundError #80

Closed
ukd1 opened this issue Mar 28, 2017 · 6 comments
Closed

NotFoundError #80

ukd1 opened this issue Mar 28, 2017 · 6 comments

Comments

@ukd1
Copy link

ukd1 commented Mar 28, 2017

Description

$ functions deploy xxxxx -l=xxxxx --entry-point=xxxxx --trigger-http -t 1

This hangs with no output, but tailing the log shows:

2017-03-28T00:05:34.040Z - error:  NotFoundError: Function xxxxx in location us-central1 in project xxxxx does not exist
    at Functions._getFunctionNotFoundError (/Users/russ/Sites/coverage/gcp-functions/node_modules/@google-cloud/functions-emulator/src/model/functions.js:544:17)
    at adapter.getFunction.then (/Users/russ/Sites/coverage/gcp-functions/node_modules/@google-cloud/functions-emulator/src/model/functions.js:579:23)
    at process._tickCallback (internal/process/next_tick.js:103:7)

q: why does it need to exist? (it does exist, but why is it even bothering to check?)

Steps to reproduce

For me, deploy the function. I've attempted to re-auth and still the same. The project does exist.

Thanks!

@jmdobry
Copy link
Contributor

jmdobry commented Apr 4, 2017

I just tried to reproduce with:

  1. npm uninstall -g @google-cloud/functions-emulator

  2. rm -rf ~/.config/configstore/@google-cloud/

  3. Verify there are no Emulator processes running.

  4. npm install -g @google-cloud/functions-emulator

  5. functions config set projectId my-project-id

     projectId set to: "my-project-id"
     You must restart the Emulator for changes to take effect...
    
  6. functions start

     Google Cloud Functions Emulator STARTED
     No functions deployed ¯\_(ツ)_/¯. Run functions deploy --help for how to deploy a function.
    
  7. functions config list -j

     {
       "grpcHost": "localhost",
       "grpcPort": 8009,
       "logFile": "logs/my-project-id.log",
       "region": "us-central1",
       "restHost": "localhost",
       "restPort": 8008,
       "service": "rest",
       "storage": "configstore",
       "supervisorHost": "localhost",
       "supervisorPort": 8010,
       "timeout": 60000,
       "useMocks": false,
       "verbose": false,
       "projectId": "my-project-id"
     }
    
  8. mkdir test_dir

  9. touch test_dir/index.js

  10. echo "exports.testFunc = (req, res) => res.send('success!');" > test_dir/index.js

  11. functions deploy testHttp -l=./test_dir --trigger-http --entry-point=testFunc -t 1

     Function testHttp deployed.
     ┌─────────────┬────────────────────────────────────────────────────────────────────────────────────────────────────┐
     │ Property    │ Value                                                                                              │
     ├─────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────┤
     │ Name        │ testHttp                                                                                           │
     ├─────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────┤
     │ Entry Point │ testFunc                                                                                           │
     ├─────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────┤
     │ Trigger     │ HTTP                                                                                               │
     ├─────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────┤
     │ Resource    │ http://localhost:8010/my-project-id/us-central1/testHttp                                           │
     ├─────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────┤
     │ Local path  │ /Users/jdobry/projects/test_dir                                                                    │
     ├─────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────┤
     │ Archive     │ file:///var/folders/jm/wt5pk0d1641bjbc4mt5pz6r800_933/T/us-central1-testHttp-40655aFa4cNCvJAyZ.zip │
     └─────────────┴────────────────────────────────────────────────────────────────────────────────────────────────────┘
    
  12. curl -X POST -H "Content-Type: application/json" -d '{"message":"this is a test"}' http://localhost:8010/my-project-id/us-central1/testHttp

     success!
    

Is there something I can do differently to reproduce the behavior you're experiencing?

@zthomas
Copy link

zthomas commented Apr 7, 2017

I'm seeing this issue as well. The problem for me is that if there's an error in the deployment process it just hangs sometimes. It seems to handle synchronous errors properly but I think some async errors will cause it to stall indefinitely.

What I would like to see here is either a progress log of the deployment or some error messages. It just gets stuck without any debugging information. The logs has this cryptic unrelated message about not finding the function being deployed (probably due to failing some automatic status check).

Here's a minimal reproducible setup that I came up with.

  • For my case, I fixed it by just moving the admin.database() out of the global environment and into a request handler. But

/functions/index.js

const functions = require('firebase-functions')
const admin = require("firebase-admin")
const serviceAccount = require('./secrets/project_xxx_creds.json')
const credential = admin.credential.cert(serviceAccount)
admin.initializeApp({
 credential,
 databaseURL: 'https://project_xxx.firebaseio.com'
});
const db = admin.database()
exports.fail = functions.https.onRequest((req, res) => {
 res.send('ok')
})

deploy:

functions deploy fail --trigger-http

logs: functions logs read

2017-04-07T19:42:38.205Z - error:  NotFoundError: Function fail in location us-central1 in project xxxxxx does not exist
    at Functions._getFunctionNotFoundError (/Users/xxx/.nvm/versions/node/v7.4.0/lib/node_modules/@google-cloud/functions-emulator/src/model/functions.js:544:17)
    at adapter.getFunction.then (/Users/xxx/.nvm/versions/node/v7.4.0/lib/node_modules/@google-cloud/functions-emulator/src/model/functions.js:579:23)
    at process._tickCallback (internal/process/next_tick.js:103:7)

@Alex-Mann
Copy link

@jmdobry I followed the steps you listed but it seems that the local server does not respond to any request and it just hung up when I try it.

@jmdobry
Copy link
Contributor

jmdobry commented Apr 13, 2017

I released 1.0.0-alpha.16, can you see if it works better for you?

@Alex-Mann
Copy link

Works for me now. To deploy a specific file it would make sense to do something along the lines of functions deploy helloWorld.js --trigger-http. What are your thoughts on this?

@jmdobry
Copy link
Contributor

jmdobry commented Apr 14, 2017

The important thing to note is that when you deploy, it finds your function by doing a require call in the directory specified by the --local-path option (which defaults to the current working directory). Therefore, it will find your function based on the require call's algorithms, e.g. look for an index.js file, then look at the "main" entry of the package.json file if there is one, then recurse upwards, etc.

This would work:

  1. cd my-project/

  2. ls -l

    helloWorld.js
    package.json
    
  3. cat package.json

    {
      "name": "my-app",
      "main": "./helloworld.js"
    }
    
  4. cat helloWorld.js

    exports.helloWorld = (req, res) => res.send('ok').end();
    
  5. functions deploy helloWorld --trigger-http

    which is short for:

    function deploy helloWorld --local-path=. --trigger-http
    

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants