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

Wait for writing to tmp fiels before handling zip stream close #1093

Merged
merged 4 commits into from
Feb 5, 2020

Conversation

sohai
Copy link

@sohai sohai commented Jan 27, 2020

I'm having a hard time to write a failing test without those changes but in one commercial project, we have tests that were flaky without this.

Copy link
Member

@alubbe alubbe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So if I understand this correctly, this is a race condition in which we could iterate through each entry and trigger the close event before the tmp callback is triggered, so therefore this.waitingWorkSheets would be empty? I can't think of a way of testing this, but good catch

@sohai
Copy link
Author

sohai commented Jan 27, 2020

I moved resolving promise to finish listener of tempStream to handle a rare case when zip close event occurs before entry.pipe(tempStream); finish

@alubbe
Copy link
Member

alubbe commented Jan 28, 2020

@Siemienik @guyonroche I think we should merge this, but I'm not sure if we can write a test here. What do you think?

@Siemienik
Copy link
Member

This is not a perfect practice to commit something without tests.

mhmm... could you test emitting error? (Do you know any situation that should throw an exception?)

@alubbe
Copy link
Member

alubbe commented Feb 3, 2020

Maybe we could use proxyquire? I think a tmp failure is really unlikely, the issue as I understand it is actually that the tmp callback could potentially get called AFTER the zip's close event has already been triggered, so this.waitingWorkSheets is empty or has less members than it should

@sohai
Copy link
Author

sohai commented Feb 4, 2020

@Siemienik I added one test. I totally understand that this is not good practice to commit something without tests but as I mentioned I could not figurated out how to do that properly, please let me know if you have some better ideas to test it.

@alubbe alubbe merged commit 2bb69c5 into exceljs:master Feb 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants