firecrawl / firecrawl/pdf-inspector
wasm: expose DetectionConfig/ScanStrategy — { strategy: "full" } is silently ignored (always Sample(8))
- Dominant language
- Rust
- Stars
- 19.1k
- Forks
- 1.3k
- Avg merge
- 9h 21m
- Merged PRs (30d)
- 51
Description
## Summary
`@firecrawl/pdf-inspector-wasm` (0.1.1) does not expose the detection scan strategy. The
binding always runs the library default `Sample(8)`, and passing a config object with
`{ strategy: "full" }` is **silently accepted but ignored** — no error, no behavior change.
The Node (napi) binding exposes full-scan behavior; the WASM binding appears to map to
upstream commit `5dfff596eb72b080b201095fa2a8cf528ace1dbe`, where `DetectionConfig` /
`ScanStrategy` is not surfaced in the wasm API.
## Issue found because...
For page-heterogeneous documents (e.g. mixed native/scanned binders), `Sample(8)` produces
document-level answers but cannot guarantee per-page coverage — which is exactly what edge
deployments want the WASM build for (cheap per-page OCR routing in Cloudflare Workers).
Silent acceptance of the ignored option also makes the gap easy to miss: results look
plausible and agree with the Node binding on homogeneous documents.
## Repro
```js
import initSync, { detectPdf } from "@firecrawl/pdf-inspector-wasm" // 0.1.1
// (Workers: static CompiledWasm import + initSync({ module }) — works fine)
const a = detectPdf(bytes)
const b = detectPdf(bytes, { strategy: "full" }) // silently ignored
// a and b are identical; pages beyond the sampled set are never inspected
```
## Ask
1. Expose `DetectionConfig` (at minimum `ScanStrategy: EarlyExit | Sample(n) | Full | Pages`)
in the WASM binding, mirroring the Rust/Node API.
2. Until then: throw or warn on unknown/unsupported config fields instead of silently
ignoring them.
## Environment / measurements (in case useful)
Tested under Cloudflare `wrangler dev --local` (workerd, wrangler 4.113.0), static
`CompiledWasm` module + `initSync` shim:
- deploy bundle: 4.63 MiB raw / 2.08 MiB gzip / 1.25 MiB brotli — comfortably within
Workers limits
- warm detector wall time: 175 ms median for a 223-page PDF, 31 ms for a 344-page scanned PDF
- no runtime API gaps after the init shim
The library is otherwise exactly what we hoped to run at the edge — happy to test a
prerelease build that exposes the strategy.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start at the WASM binding's detectPdf entry point and compare its configuration handling with the Rust/Node API and upstream commit 5dfff596eb72b080b201095fa2a8cf528ace1dbe. Done means DetectionConfig and the listed ScanStrategy variants are exposed, full scanning changes behavior as expected, and unsupported config fields are no longer silently ignored.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, rust, wasm
- Domain
- api
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100