toondaey / nestjs-pdf

Nest js pdf generator
MIT License
80 stars 37 forks source link

Creation PDF simultaneously fails #190

Open cod opened 2 years ago

cod commented 2 years ago

Use this library in RabbitMQ consumer app and faced with simultaneous PDF Docs generation problem:

Request for 3 docs producess this: Doc 1. started Doc 2. started Doc 3. started

Doc 3. done successfully Doc 2. [Nest] 811334 - 06/06/2022, 1:12:07 PM ERROR [RpcExceptionsHandler] ENOENT: no such file or directory, open '/tmp/html-pdf-811334.pdf' Doc 1. [Nest] 811334 - 06/06/2022, 1:12:07 PM ERROR [RpcExceptionsHandler] ENOENT: no such file or directory, open '/tmp/html-pdf-811334.pdf'

As I understand, this is the problem: in lib/pdf.default.ts

export const defaultCreateOptions = {
    filename: join(tmpdir(), `html-pdf-${process.pid}.pdf`),
};

Think using random name for each file will solve the problem.

manueljishi commented 1 year ago

Hello @cod I'm currently facing the same issue. Did you manage to solve the problem? If so, how did you do it? Thank you very much!

cod commented 1 year ago

Hi @manueljishi Unfortunately, all my tries failed and I've switched to @ricktechs/nestjs-puppeteer

manueljishi commented 1 year ago

Hi @cod, that sounds really bad haahaha. I'll have to start thinking about changing. Thank you very much