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);
}
);
});