1

I have a cloud code function that was working for a few weeks and then started crashing yesterday. It causes the whole parse server to shut down and doesn't produce any logging, making it very difficult to debug. I tried calling the the Stripe API directly with node and my customer ID string hard coded and it worked fine. Any ideas why this would randomly stop working in Parse?

Here's my cloud function, all it does is get the active users Stripe ID and retrieve their customer object (the customer id is retrieved and logged successfully):

var stripe = require('stripe')(STRIPE_KEY);

var winston = require('winston');
var logger = new (winston.Logger)({
  transports: [
    new (winston.transports.File)({ 
      filename: 'logs/parsecloud.log',
      handleExceptions: true,
      humanReadableUnhandledException: true
    })
  ]
});

Parse.Cloud.define('customer', function(req, res) {
  if (!req.user) {
    logger.error('/customer no user session');
    res.error("No user session");
    return;
  }

  var stripeId = req.user.get('stripeId');
  logger.info('getting stripe customer for', stripeId);

  stripe.customers.retrieve(stripeId).then(
    function(customer) {
      logger.info('got customer for ', stripeId);
      res.success(customer);
    },
    function(err) {
      logger.error('customer error', stripeId, err);
      res.error(err);
    }
  );
});
  • It seems like it might have something to do with pm2 restart on change settings, but my logs are not in my cloud code directory, so I'm not sure what would trigger the change. – mer10z_tech Apr 14 '17 at 20:33
0

I fixed this by re-installing parse server with npm. I was using an older version of parse server and every few months it would just randomly stop working, and the only way to fix it was to remove it and re-install it. Maybe there was some cache or something that just got too big over time and eventually caused this problem.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.