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

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.