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

File Streams Not Closing on appendPage #177

Open
stormflurry opened this issue Mar 10, 2020 · 1 comment
Open

File Streams Not Closing on appendPage #177

stormflurry opened this issue Mar 10, 2020 · 1 comment
Labels

Comments

@stormflurry
Copy link

Hi, I've run into a bug where file streams are not closing on using appendPage.

// create a merged pdf                    
var pdfDoc = new HummusRecipe('new', appRoot + '\\labels\\full_' + params.orderId + '.pdf');
    for (p=0; p<pdfFiles.length; p++){     
        pdfDoc.appendPage(pdfFiles[p], p).endPage();
        }                          
await pdfDoc.endPDF();

I immediately do a cleanup on the files that were merged into one and each time the last file merged files to unlink() properly because it's file stream is still open and not properly cleaned up by hummus-recipe.

If I add a pause of 1000 ms then it fixes the error but something is not immediately releasing the file stream after .endPage().

Please fix this bug.

@PhakornKiong
Copy link

The bug is still reproducible if I do the following

const pdfDoc = new HummusRecipe(inputPath, outputPath);
pdfDoc.encrypt(option).endPDF(() => {});
    
fs.unlink(inputPath) // Error: EBUSY: resource busy or locked, unlink

Somehow a pause of 1000ms as reported is not working for me, I need to do nearly 10000ms for it to works.

const pdfDoc = new HummusRecipe(inputPath, outputPath);
pdfDoc.encrypt(option).endPDF(() => {});
    
setTimeout(() => {
  fs.unlink(inputPath);
}, 10000);
    

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

No branches or pull requests

3 participants