Skip to content

Help Debugging main.js syntax issues after migration #2948

Closed

Description

@KetchupMoose

I need help migrating my parse server and was directed here by the parse support page.

I have finished the database migration to an mLab database and have the parse server example running in heroku.

My project runs perfectly at retrieving my current data with the default parse server example main.js file, but I would like to still run ParseServer jobs from the client like in this iOS example so I would like to use my own main.js file.

[PFCloud callFunction:@"publishCard" withParameters:@{
@"cardID" : card.cardPF.objectId,
} error:&error];

When I try to run my project with the following file as main.js (I've renamed it newmainjs just for visibility), it doesn't let me login with parse at all anymore from my iOS Client--so it seems to be triggering errors and I have no idea how to debug it as it's not covered in the migration tutorial.

https://github.com/KetchupMoose/cardgameserver/blob/master/cloud/newmain.js

I am very amateur at backend/node so I would really appreciate some support, as I relied on Parse for a lot of things before.

Activity

  1. flovilmart commented on Oct 27, 2016

    @flovilmart
    Contributor

    if your file is now named newmain.js you should probably update your server cloud option to cloud/newmain.js. here: https://github.com/KetchupMoose/cardgameserver/blob/master/index.js#L16

  2. KetchupMoose commented on Oct 28, 2016

    @KetchupMoose
    Author

    sorry--the issue wasn't that it's named newmain.js--I've just renamed it that way so I could show the file that I want to use. The issue is that if I use that file (newmain.js) as my main.js file, instead of the example main.js that is included in parse-server-example--then core functionality of parse server breaks, like logins suddenly don't work.

    I did some more testing and tried changing my main.js file to include just one function from my newmain.js file, presumably one that doesnt have any syntax errors, and then my parse implementation worked again and I was able to login and use other functions on the client.

    Is there any way to debug your main.js file to know if it has syntax errors? Because it seems like if I upload something that has errors, the whole functionality of parse just seems to not work.

  3. changed the title [-]Hello[/-] [+]Help Debugging main.js syntax issues after migration[/+] on Oct 28, 2016
  4. steven-supersolid commented on Nov 1, 2016

    @steven-supersolid
    Contributor

    You can try running your main.js through a linter such as eslint to find errors. An IDE like Webstorm can find them too.

    I recommend you write some unit/integration tests for each endpoint of your main.js - check out package.json and helper.js in parse-server to see how to set up a local server as part of tests.

    You could also just run your server locally with your bugged main.js and likely you'll see some errors on the console at startup or when sending a request via curl.

    I don't think it is going to be possible to catch all errors when cloud code is loaded, and the responsibility for this has to lie with the application and not parse-server. Perhaps we could try/catch when mounting cloud code endpoints and display an error.

  5. flovilmart commented on Nov 1, 2016

    @flovilmart
    Contributor

    That seems dangerous to deploy with caught exceptions as one user may have security logic in it's hooks. Unlike parse.com where cloud code was loaded at each request, we actually need all triggers and functions at startup time (given the current architecture)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions