Hopding / pdf-lib

Create and modify PDF documents in any JavaScript environment
https://pdf-lib.js.org
MIT License
6.97k stars 671 forks source link

embedPng stuck in infinity loop #1146

Open lukasa1993 opened 2 years ago

lukasa1993 commented 2 years ago

What were you trying to do?

to embed png into pdf

How did you attempt to do it?

https://github.com/lukasa1993/pdf-lib-issue

What actually happened?

process stuck in loop

What did you expect to happen?

to embed image into pdf

How can we reproduce the issue?

here is the full POC where you can run working sample and infinite loop sample

so you can run node test2.js for working as expected sample and node test.js for looped one

https://github.com/lukasa1993/pdf-lib-issue

Version

1.17.1

What environment are you running pdf-lib in?

Node

Checklist

Additional Notes

so problem was that image PNG was not properly uploaded to server and then it was trying to embed it into pdf while MacOS preview still can show part of PNG pdf-lib just stuck in loop and hangs whole JS process cant even guard agains it with promise race condition i couldn't figure out any workaround

dschi commented 1 month ago

Did you ever find a way around this?

lukasa1993 commented 1 month ago

no, i just try catch it and embed as jpg if it throws if both throw i just abandon that image