Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"invalid distance too far back" error when running on Next.js 14 with Turbopack #1619

Open
2 tasks done
yan3321 opened this issue Apr 19, 2024 · 1 comment
Open
2 tasks done

Comments

@yan3321
Copy link

yan3321 commented Apr 19, 2024

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.

@SulTanvai0
Copy link

the issue is here "next dev --turbo" turbo isn't stabel yet try "dev": "next dev" $- npm run dev

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants