Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cloud code functions not getting called #385

Closed
oyvindvol opened this issue Feb 12, 2016 · 8 comments
Closed

Cloud code functions not getting called #385

oyvindvol opened this issue Feb 12, 2016 · 8 comments
Labels
type:question Support or code-level question

Comments

@oyvindvol
Copy link

I have set up parse-server on Heroku, but I am having trouble with the cloud code. I used the parse-server-example, and replaced the contents of main.js with my own:

console.log('##### TEST');

Parse.Cloud.afterSave('SomeClass', function(request) {
  console.log('##### INSIDE AFTER SAVE');
});

And this is my parse-server setup:

var api = new ParseServer({
  databaseURI: 'mongodb://...',
  cloud: __dirname + '/cloud/main.js',
  appId: '...',
  masterKey: '...',
  dotNetKey: '...',
  clientKey: '...',
  fileKey: '...',
  serverURL: 'https://<appname>.herokuapp.com/parse',
  push: {
    ios: [
      {
        pfx: '....p12',
        bundleId: '<bundle-id>',
        production: false
      }, 
      {
        pfx: '....p12',
        bundleId: '<bundle-id>',
        production: true
      }
    ]
  }
});

When i run heroku logs in the terminal i can see the "### TEST" getting printed after start up. But when I save an object of the specified type, nothing is printed in the logs, so it seems that the beforeSave and afterSave isn`t getting called at all.

@liangjun-jiang
Copy link

what's your cloud function looks like? Did you really save a 'SomeClass' object in your cloud function?

@oyvindvol
Copy link
Author

The SomeClass object is saved from a client. The code I posted is my entire main.js.

@jiawenzhang
Copy link

did you have
Parse.serverURL="https://fast-badlands-XXXX.herokuapp.com/parse/";

in your main.js?

@oyvindvol
Copy link
Author

No, the serverURL is set in index.js, in my ParseServer initialization. Is that wrong?

@gfosco
Copy link
Contributor

gfosco commented Feb 13, 2016

Are you sure your parse server instance is receiving that object save and processing it?.. for troubleshooting purposes, it's important to know.. are you using an app Id which is also a parse.com app id? Is the parse app also connected to the same database, etc.. I'd run the server with the environment variable VERBOSE=1 and make sure the save was received.

@oyvindvol
Copy link
Author

No, I am not sure of that, and don`t quite know how to check it. This is the situation:

  • I clicked the Heroku button on the parse-server-example, and set up a Heroku app
  • I started the database migration from parse to my new MongoLab base
  • I copied keys from parse, into my own Parse Server initialisation (appId, masterKey, fileKey, clientKey)
  • I use a client (.NET-client) to make changes to an existing "SomeClass" object (this client connects to the parse database)
  • I verify that the change was made in the parse database, and it was synced to the MongoLab database
  • I thought that at the point the data was synced to the MongoLab instance, the afterSave() would get called
  • I`ve also tried adding records directly to the MongoLab database

@gfosco
Copy link
Contributor

gfosco commented Feb 14, 2016

The .NET SDK would make a call with the dotNetKey, which if you haven't configured would cause a problem. Here's an easy test... Change the appId for your ParseServer instance and also in your .Net app. I recommend removing any clientKey/javascriptKey/dotNetKey/restAPIKey options.

@oyvindvol
Copy link
Author

When going through my .NET client, and not just saving objects directly in the MongoLab database, the cloud functions were called as they should.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:question Support or code-level question
Projects
None yet
Development

No branches or pull requests

5 participants