The newer versions of ethers appears to be unstable. It's throwing the following error, so downgrading the ethers version helped in solving this problem.
const provider = new ethers.providers.JsonRpcProvider(process.env.RPC_URL)
^
TypeError: Cannot read properties of undefined (reading 'JsonRpcProvider')