Next.js Discord

Discord Forum

On-Demand Revalidation works locally but partially fails in production with 504 errors.

Unanswered
Maruthi posted this in #help-forum
Open in Discord
On-Demand Revalidation works as expected in a local environment but encounters issues in production. While some pages revalidate successfully, others do not, resulting in a 504 Gateway Timeout error. The error persists even after implementing recommended error handling strategies, specifically when attempting to revalidate the path '/en/wedding/engagement'.

Our team has been troubleshooting this issue, but we haven't been able to resolve it yet.

We value your expertise and would greatly appreciate your assistance in identifying what might be causing this issue and any suggestions for resolving it. If possible, could you please take a look and provide your insights on how we could address this?

For more details of the error, I have attached a screenshot of the error logged on Vercel's server.

We have used below code as per the documentation:

export default async function handler(req, res) {
// Check for secret to confirm this is a valid request
if (req.query.secret !== process.env.MY_SECRET_TOKEN) {
return res.status(401).json({ message: 'Invalid token' })
}

try {
// this should be the actual path not a rewritten path
// e.g. for "/blog/[slug]" this should be "/blog/post-1"
await res.revalidate('/path-to-revalidate')
return res.json({ revalidated: true })
} catch (err) {
// If there was an error, Next.js will continue
// to show the last successfully generated page
return res.status(500).send('Error revalidating')
}
}

Thank you very much for your attention to this matter. We look forward to hearing from you soon.

Best regards,
Maruthi

0 Replies