(Created on )

Puppeteer: Cannot unregister unknown handler: {value}

unregisterCustomQueryHandler receives a name that is not registered.


unregisterCustomQueryHandler receives a name that is not registered.

Error message

Cannot unregister unknown handler: {value}

{value} is replaced by the value shown in your error message.

How this error happens

Removing a handler that was never registered, or removing it twice, fails because its name is absent from the registry.

The snippets use the imported Puppeteer class for its static query-handler methods. The fix uses the same import.

import {
    Puppeteer,
} from "puppeteer";

Puppeteer.unregisterCustomQueryHandler(
    "notRegistered"
);

How to fix

Only unregister a name that your setup registered and that is still present.

if (Puppeteer.customQueryHandlerNames().includes("custom")) {
    Puppeteer.unregisterCustomQueryHandler(
        "custom"
    );
}

Things to keep in mind

Avoid removing another test or plugin’s handlers from a shared Puppeteer instance.

All Puppeteer errors

Keep Reading

Puppeteer Guides

All Guides →