Skip to content

Expose parseFilter binding to surface parse errors in JS#681

Draft
ShivanKaul wants to merge 1 commit into
masterfrom
js-expose-parse-filter
Draft

Expose parseFilter binding to surface parse errors in JS#681
ShivanKaul wants to merge 1 commit into
masterfrom
js-expose-parse-filter

Conversation

@ShivanKaul

Copy link
Copy Markdown
Collaborator

JS callers using addFilter only got a boolean and could not learn why a rule was rejected.

This PR exposes the adblock::lists::parse_filter function as a standalone parseFilter export returning { supported, filterType, error }, where error is the FilterParseError Display string on failure. addFilter's existing boolean return is left unchanged.

JS callers using addFilter only got a boolean and could not learn
why a rule was rejected, nor whether it was a network or cosmetic
filter. This made it impossible to audit a filter list for
adblock-rust compatibility without mutating a FilterSet.

Expose the pure adblock::lists::parse_filter as a standalone
parseFilter export returning { supported, filterType, error }, where
error is the FilterParseError Display string on failure. addFilter's
existing boolean return is left unchanged to avoid breaking callers,
since rejected rules are a normal outcome when loading real lists.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rust Benchmark

Details
Benchmark suite Current: 8517775 Previous: d789160 Ratio
rule-match-browserlike/brave-list 1775659713 ns/iter (± 5487420) 2294657228 ns/iter (± 16160555) 0.77
rule-match-first-request/brave-list 1003100 ns/iter (± 6386) 1251222 ns/iter (± 4974) 0.80
blocker_new/brave-list 108917432 ns/iter (± 679457) 138752639 ns/iter (± 1395429) 0.78
blocker_new/brave-list-deserialize 25656979 ns/iter (± 1814357) 32916216 ns/iter (± 223578) 0.78
memory-usage-final/brave-list-initial 11354668 B/iter (± 0) 11354668 B/iter (± 0) 1
memory-usage-final/brave-list-1000-requests 2612449 B/iter (± 0) 2612449 B/iter (± 0) 1
memory-usage-max/brave-list-initial/max 63576547 B/iter (± 0) 63576547 B/iter (± 0) 1
memory-usage-alloc-count/brave-list-initial/alloc-count 859915 allocs/iter (± 0) 859915 allocs/iter (± 0) 1
memory-usage-alloc-count/brave-list-1000-requests/alloc-count 74018 allocs/iter (± 0) 74018 allocs/iter (± 0) 1
url_cosmetic_resources/brave-list 155629 ns/iter (± 644) 201452 ns/iter (± 708) 0.77
cosmetic-class-id-match/brave-list 2710182 ns/iter (± 717917) 3345009 ns/iter (± 905142) 0.81

This comment was automatically generated by workflow using github-action-benchmark.

@ShivanKaul
ShivanKaul requested a review from antonok-edm June 23, 2026 05:13
@ShivanKaul
ShivanKaul marked this pull request as draft June 23, 2026 05:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant