Puppeteer not working at render production

this code is not working at render production but working fine in local machine.

means if (request.resourceType() === “media”) {
console.log(“Media request intercepted:”, request.url());
browser.close();
resolve(request.url());

i donot get resourceType() === “media” at render production level…
same is working fine in local machine…there is not login require for this purpose… i have already checked in local machine crome testing browser is used for the same purpose and i am not login there

const getDirectVideoUrl = async (instagramUrl) => {
const browser = await puppeteer.launch({ headless:“new” });
const browserVersion = await browser.version();
console.log(‘Chromium Version:’, browserVersion);
const page = await browser.newPage();

// Enable request interception

await page.setRequestInterception(true);
console.log(“1 setRequestInterception(true) this done”);

// // Log all responses
page.on(“response”, (response) => {
console.log(“Response URL:”, response.url());
});

// Navigate to the URL
console.log(“5 just start of navigation”);
page.goto(instagramUrl, { waitUntil: “domcontentloaded” }).catch((error) => {
reject(error);
});
console.log(“6 page navigated”);

// Create a promise that resolves when the video URL is found
const videoUrlPromise = new Promise((resolve, reject) => {
console.log(“2 just enter inside new promise”);
page.on(“request”, (request) => {
console.log(“3. request event listned triggered”);
if (request.resourceType() === “media”) {
console.log(“Media request intercepted:”, request.url());
browser.close();
resolve(request.url());
} else {
console.log(“4. request continuingggggg”,request.url());
console.log(“Resource Type:”, request.resourceType());
request.continue();
}
});

page.on("error", (error) => {
  console.error("Error:", error);
  browser.close();
  reject(error);
});

});

// Wait for the promise to resolve
const videoUrl = await videoUrlPromise;

return videoUrl;
};

for example i have given url below: approach is not working at production for any video url…but working in local machine…

Hi there,

Can you please provide any additional detail about why you think this behavior is due to Render’s service? There can be many reasons why an application’s behavior on a local machine will be different when running on Render (or any server, for that matter): versioning, configuration, environment data, etc.

I recommend checking out this Render blog post about why things might be behaving differently on Render than locally and ensuring all of those factors have been addressed. You may also want to reach out to a nodejs community for assistance.

If you’re still not able to find a solution after looking into the above, feel free to respond so we can take another look.

Regards,
Mike


Render Support Engineer, MT (UTC-6)

This is because the chrome browser is not available in render machine. You need to install chrome browser before deployment.