RangeError: Maximum Call Size Exceeding, Stripe session create

I’m using stripe(both server and client side using sessions) for payments. I’m using node on the backend and react on frontend. I have started building my server route for creating a new session.

Route –

router.route('/new-session/:orderId').get(protectMiddleware, async (req, res) => {
    try {
        const order = await Order.findById(req.params.orderId);
        const domain = `${req.protocol}://${req.get('host')}`;

        const session = await stripe.checkout.sessions.create({
            payment_method_types: ['card'],
            line_items: order.orderItems,
            mode: 'payment',
            success_url: `${domain}/`,
            cancel_url: `${domain}/order/${req.params.orderId}`,
            customer_email: req.user.email,
            client_reference_id: req.params.orderId,
        });

        res.status(200).json({ status: 'success', session });
    } catch (error) {
        console.log(error);
        res.send(error.message);
    }
});

The error I’m getting is that –

[0] RangeError: Maximum call stack size exceeded
[0]     at stringify (/Users/akash/Code/Projects/ProShop/node_modules/qs/lib/stringify.js:47:35)
[0]     at stringify (/Users/akash/Code/Projects/ProShop/node_modules/qs/lib/stringify.js:125:33)
[0]     at stringify (/Users/akash/Code/Projects/ProShop/node_modules/qs/lib/stringify.js:109:33)
[0]     at stringify (/Users/akash/Code/Projects/ProShop/node_modules/qs/lib/stringify.js:125:33)
[0]     at stringify (/Users/akash/Code/Projects/ProShop/node_modules/qs/lib/stringify.js:109:33)
[0]     at stringify (/Users/akash/Code/Projects/ProShop/node_modules/qs/lib/stringify.js:125:33)
[0]     at stringify (/Users/akash/Code/Projects/ProShop/node_modules/qs/lib/stringify.js:109:33)
[0]     at stringify (/Users/akash/Code/Projects/ProShop/node_modules/qs/lib/stringify.js:125:33)
[0]     at stringify (/Users/akash/Code/Projects/ProShop/node_modules/qs/lib/stringify.js:109:33)
[0]     at stringify (/Users/akash/Code/Projects/ProShop/node_modules/qs/lib/stringify.js:125:33)
[0]     at stringify (/Users/akash/Code/Projects/ProShop/node_modules/qs/lib/stringify.js:109:33)
[0]     at stringify (/Users/akash/Code/Projects/ProShop/node_modules/qs/lib/stringify.js:125:33)
[0]     at stringify (/Users/akash/Code/Projects/ProShop/node_modules/qs/lib/stringify.js:109:33)
[0]     at stringify (/Users/akash/Code/Projects/ProShop/node_modules/qs/lib/stringify.js:125:33)
[0]     at stringify (/Users/akash/Code/Projects/ProShop/node_modules/qs/lib/stringify.js:109:33)
[0]     at stringify (/Users/akash/Code/Projects/ProShop/node_modules/qs/lib/stringify.js:125:33)

Leave a Comment