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

TypeError: Cannot read property 'then' of undefined #20

Closed
kaspermarstal opened this issue Dec 26, 2016 · 4 comments
Closed

TypeError: Cannot read property 'then' of undefined #20

kaspermarstal opened this issue Dec 26, 2016 · 4 comments
Labels

Comments

@kaspermarstal
Copy link

kaspermarstal commented Dec 26, 2016

Description

Promises are not handled as expected by the cloud-functions emulator. For example, all functions from the nodejs-docs-samples/functions/datastore test suite that rely on promises return the following error:

{
  "stack": "TypeError: Cannot read property 'then' of undefined\n    at Object.set (/Users/kasper/Development/google-app-engine/server/modules/datastore/functions.js:69:5)\n    at Object.invoke (/usr/local/lib/node_modules/@google-cloud/functions-emulator/src/emulator/invoker.js:38:15)\n    at Object._invoke (/usr/local/lib/node_modules/@google-cloud/functions-emulator/src/emulator/index.js:439:19)\n    at /usr/local/lib/node_modules/@google-cloud/functions-emulator/src/emulator/index.js:383:14\n    at Layer.handle [as handle_request] (/usr/local/lib/node_modules/@google-cloud/functions-emulator/node_modules/express/lib/router/layer.js:95:5)\n    at next (/usr/local/lib/node_modules/@google-cloud/functions-emulator/node_modules/express/lib/router/route.js:131:13)\n    at next (/usr/local/lib/node_modules/@google-cloud/functions-emulator/node_modules/express/lib/router/route.js:125:14)\n    at next (/usr/local/lib/node_modules/@google-cloud/functions-emulator/node_modules/express/lib/router/route.js:125:14)\n    at next (/usr/local/lib/node_modules/@google-cloud/functions-emulator/node_modules/express/lib/router/route.js:125:14)\n    at next (/usr/local/lib/node_modules/@google-cloud/functions-emulator/node_modules/express/lib/router/route.js:125:14)",
  "message": "Cannot read property 'then' of undefined"
}

Steps to reproduce

{
  method: `POST`,
  headers: {
    'Content-Type': `application/json`
  },
  body: {
    kind: datastore.kind.BOOK,
    key: `ilovebike`,
    value: { title: `I love bike` }
  }
}

Looking forward to using this wonderful tool!

@jmdobry
Copy link
Contributor

jmdobry commented Dec 26, 2016

Are you using the 0.4.0 version of the emulator currently published to NPM?

@kaspermarstal
Copy link
Author

Yes I am using 0.4.0. However, I was perhaps a little too trigger happy when opening this issue and after a bit of digging it seems the problem is with the porting of GoogleCloudPlatform/nodejs-docs-samples repo. I have opened a new issue at GoogleCloudPlatform/nodejs-docs-samples#284.

Thank you for your time.

@kaspermarstal
Copy link
Author

The problem persists and is not related to the issue referenced above.

@jmdobry jmdobry self-assigned this Dec 31, 2016
@jmdobry jmdobry added the bug label Dec 31, 2016
@jmdobry
Copy link
Contributor

jmdobry commented Feb 1, 2017

Resolved via GoogleCloudPlatform/nodejs-docs-samples#284

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

No branches or pull requests

2 participants