-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
doc.end() callback? #265
Comments
My workaround (I PDFkit should provide a callback method or promise): Store the writeStream in a extra variable and watch it for a change:
|
Yeah the |
I see two ways of doing it:
|
+1 for "finish callback".. this will be much more "intuitive" |
+1 for callback |
The problem with adding a callback to the For this reason, my vote is to keep PDFKit the way it is now and not to add a callback to |
I think it would be a great idea to document this then. +1 for callback — |
+1 for callback |
+1 |
+1 Thanks a lot. I was facing weird error in my execution. |
I believe it's not quite as simple as listening for the 'finish' event on the write stream, specifically in the case of errors, so I implemented the following function which returns a Promise.
Instead of calling This should correctly handle the following situations:
|
That's a nice solution. :) It would be great to see that in the library itself so that users don't have to deal with these issues. |
+1 for at least a note in the doc. |
+1 it is elementary |
I had a similar issue where I need to save the file to s3.
Worked great, thanks @spieglio. |
@SeanCannon Because sometimes i can creating pdfFile successfully with AWS lambda. But sometimes pdf file created right(pdf file size is right) while but has a error so cant open file, or sometimes pdf file created wrong(file size is look 16). I cant handle this situation. |
If anyone has trouble catching the error when a file has failed to upload, following code can be added to the function of codeandcats
|
This solved it for me:
It's a bit less verbose.. just waits before continuing. |
This fixed my issue, thanks for sharing!! |
I am creating many pdfs in a loop and in the end I am downloading all the resultant pdf's in a zip folder. |
For each PDF you're making, would you be able to create promises as shown in this thread, push them to an array, then feed that array to Promise.all and do an await on it? |
I am piping to an http response object inside a Firebase function. |
I have plan to make it fully sinchronously |
Saved my life hahah thanks! |
You are a genius and have saved my sanity. Thank you. |
Is there a way to get a callback after everything asynchronous is finished and the file is completely stored to the file system?
I can't find a way. Probably I am missing something?
The text was updated successfully, but these errors were encountered: