canvas icon indicating copy to clipboard operation
canvas copied to clipboard

PDF.js + Webpack runs into type error: Value is non of these types `String`, `Path`

Open Cybourgeoisie opened this issue 3 months ago • 1 comments

An earlier issue, #994, has been resolved as of 0.1.72. A similar issue, since that release, for all combinations of PDF.js and @napi-rs/canvas, has appeared with a similar type error:

Error: Value is non of these types `String`, `Path`, 
    at CanvasGraphics.consumePath (/Users/cybourgeoisie/Documents/Cybourgeoisie/webpack-pdfjs-napirscanvas-test/dist/626.main.js:16611:15)
    at CanvasGraphics.endPath (/Users/cybourgeoisie/Documents/Cybourgeoisie/webpack-pdfjs-napirscanvas-test/dist/626.main.js:15634:10)
    at CanvasGraphics.constructPath (/Users/cybourgeoisie/Documents/Cybourgeoisie/webpack-pdfjs-napirscanvas-test/dist/626.main.js:15543:13)
    at CanvasGraphics.executeOperatorList (/Users/cybourgeoisie/Documents/Cybourgeoisie/webpack-pdfjs-napirscanvas-test/dist/626.main.js:15104:23)
    at InternalRenderTask._next (/Users/cybourgeoisie/Documents/Cybourgeoisie/webpack-pdfjs-napirscanvas-test/dist/626.main.js:20642:37)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  code: 'InvalidArg'
}

Similar to the previous issue, this issue does not show up when running in dev, but it does show up in the built code with webpack.

I have updated the test repo with the current versions for reproduction: https://github.com/Cybourgeoisie/webpack-pdfjs-napirscanvas-test

Cybourgeoisie avatar Sep 18 '25 11:09 Cybourgeoisie

There is a potential workaround - this issue may not occur with other package builders. I am able to build and include the packages with esbuild instead of webpack, and the issue does not seem to be present.

Cybourgeoisie avatar Sep 23 '25 17:09 Cybourgeoisie

Just chiming in, I've managed to hit this with Vite/Rollup

I saw the referenced commit that seems to handle this co-authored by Claude but it looks like it's still sitting on a branch while the commit prior for UTF-16 has made it to main.

Any thoughts on when we might look at this?

The issue on my side is a bit strange where it seems to be fine on most aarchs but fails on arm64-musl on ECS only, pulling the same container and running it locally is fine.

Mythie avatar Dec 04 '25 00:12 Mythie