Puppeteer: Function with name '{value}' does not exist
Removing an exposed page function fails because its name is not registered on that page.
Removing an exposed page function fails because its name is not registered on that page.
Error message
Function with name '{value}' does not exist
{value} is replaced by the value shown in your error message.
How this error happens
removeExposedFunction can only remove a binding registered on that page. A missing name or a second removal has no binding to remove.
The snippets use an open Puppeteer page named page.
await page.removeExposedFunction(
"notRegistered"
);
How to fix
Track binding ownership and remove a function only after its registration succeeded.
await page.exposeFunction(
"readSettings",
() => {
return {
theme: "dark",
};
}
);
await page.removeExposedFunction(
"readSettings"
);
Things to keep in mind
A normal global function written by the website is not a Puppeteer exposed binding.