Commit 39f09d5
committed
fix(attachments): polyfill pdfjs DOM globals so PDF text extraction skips native canvas (ABCA-745)
After fixing the v2 API + nodeModules bundling, PDF screening still failed live:
pdfjs tried to load the native @napi-rs/canvas binding to supply DOMMatrix/
ImageData/Path2D, but the cross-platform binary isn't bundled for the Lambda's
linux-arm64 (only the build host's darwin binary resolved) → 'Cannot find native
binding' → 'DOMMatrix is not defined' → screening unavailable.
Text extraction never actually uses canvas — pdfjs only touches those globals on
its optional RENDER path. Defining them as inert no-op stubs BEFORE importing
pdf-parse makes pdfjs skip the native-canvas load entirely and extract text
headless — no native binary, host-independent. Verified: getText returns full
text with canvas forced-absent + the three stubs present.
This was platform-wide (confirm-uploads / Jira aws-samples#619 / Linear all fail-closed on
every PDF) — PDF screening has been dead since the pdf-parse v2 bump.1 parent 8db77e8 commit 39f09d5
1 file changed
Lines changed: 28 additions & 6 deletions
File tree
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
248 | 248 | | |
249 | 249 | | |
250 | 250 | | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
251 | 272 | | |
252 | 273 | | |
253 | | - | |
254 | | - | |
255 | | - | |
256 | | - | |
257 | | - | |
258 | | - | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
259 | 281 | | |
260 | 282 | | |
261 | 283 | | |
| |||
0 commit comments