"invalid distance too far back" error when running on Next.js 14 with Turbopack
yan3321 opened this issue · 3 comments
What were you trying to do?
Trying to generate a PDF
How did you attempt to do it?
Visiting an API route under the app directory in Next.js 14 while running the dev server with Turbopack
What actually happened?
Any attempts to generate the PDF result in an "invalid distance too far back" error
What did you expect to happen?
The PDF should be generated successfully
How can we reproduce the issue?
Install pdf-lib, Next.js 14, run the Turbopack dev server with next dev --turbo
Version
1.17.1
What environment are you running pdf-lib in?
Node
Checklist
- My report includes a Short, Self Contained, Correct (Compilable) Example.
- I have attached all PDFs, images, and other files needed to run my SSCCE.
Additional Notes
While I do not have a SSCCE, I have eventually tracked this error down to the pako
library with is apparently a port of zlib
. pdf-lib
and its dependencies are relying on an older v1 version.
By manually overriding pako
to v2 (using pnpm in my case) in package.json
:
"pnpm": {
"overrides": {
"pako": "^2.1.0"
}
}
For my specific implementation, I no longer run into any issues with the PDF generation and it works as expected.
As an alternative, the normal Webpack dev server can still be used with no problems.
the issue is here "next dev --turbo" turbo isn't stabel yet try "dev": "next dev" $- npm run dev