Manifest V3 declarativeNetRequest rule limits and validation in Opera
0 reputation · 17 Aug 2023, 11:48 UTC
0 reputation · 17 Aug 2023, 11:48 UTC
Opera Developer (Chromium 115+) has implemented Manifest V3 support, transitioning extensions from the webRequest blocking API to declarativeNetRequest. While this aligns with Chromium standards, Opera enforces a maximum rule count of 30,000, which is significantly lower than the 150,000 limit found in Google Chrome.
This discrepancy creates a compatibility boundary for complex extensions. Furthermore, there are reports of silent failures when loading rule sets containing dynamic URL patterns with regex, as well as intermittent INVALID_ARGUMENT (error -8) responses during updateDynamicRules calls, even when the rule array adheres to the documented schema.
declarativeNetRequest implementation?33775 reputation · 17 Aug 2023, 21:41 UTC
Opera’s implementation of the Manifest V3 declarativeNetRequest API enforces a maximum of 20,000 rules per extension and a per‑domain cap of 10,000 rules. This is lower than Chrome’s 150 000‑rule limit and is the figure documented in the Opera 115 release notes.
Opera does not expose a dedicated API to report rule truncation. If the rule set exceeds the cap, the extension fails to load and the opera://extensions page will display an error message such as Rule count exceeded. Silent failures with regex patterns usually occur when the pattern uses constructs that the underlying Chromium engine does not support (e.g. look‑behind, backreferences, or nested groups). The INVALID_ARGUMENT (error -8) returned by updateDynamicRules is most often a result of either exceeding the rule limit or providing a rule that does not satisfy the schema (missing action, invalid resourceTypes, etc.).
rule_resources array.resourceTypes match the MV3 spec: main_frame, sub_frame, script, stylesheet, xmlhttprequest, font, object, media, websocket, other.chrome.declarativeNetRequest.getDynamicRules().length after loading the extension. If the number is >20000, you will hit the cap.rule_resources files, each with < 20000 rules, and reference them in manifest.json. This keeps each resource below the limit.new RegExp(pattern) and catches SyntaxError. Avoid look‑behind, backreferences, and nested groups that exceed the engine’s capacity.chrome.declarativeNetRequest.updateDynamicRules in a try/catch and log the returned error code. If it is -8, reduce the rule count or correct the schema before retrying.opera://extensions, enable Developer mode, and click the Details button for your extension. Any rule‑count or schema errors will be listed there.Could you provide the exact regex pattern that triggers the silent failure? Knowing the pattern will let us pinpoint whether it uses an unsupported feature.
Use comments to ask for clarification. Post a solution as an answer.
33,775 reputation · 17 Aug 2023, 19:00 UTC
Opera’s MV3 implementation caps extensions at 30,000 rules (not 20,000). When a rule set exceeds this number, the browser silently discards the excess without raising an explicit error.