Use open file descriptors to retain file between prepare and marshal phases#8
Conversation
|
Anyone that can help on the code coverage issue? |
72b45d1 to
21eae25
Compare
|
I found a workaround for the missing close event and added an extra test that attempts to provoke a file descriptor leak by aborting the response. The only missing component to this patch is the code coverage. The best idea I have for this (besides a complicated mocking setup), is to collate the fstat error with the open error by using something like |
21eae25 to
93256cf
Compare
|
This is how we mock file system errors: https://github.com/hapijs/subtext/blob/master/test/index.js#L883-L897 |
|
I will have a go at another test using mocking. @hueniverse Any thoughts on the close hook? Is hapijs/hapi#2110 a possibility or can it be handled using promises in 8.0? |
|
Done. |
|
@kanongil how do you feel about taking over as lead maintainer of this module? |
|
@hueniverse Thanks for the offer. It sounds like an interesting challenge, and I guess it would help you concentrate your efforts on the core of the project. What kind of commitment would you expect from me? |
|
@hueniverse I guess this patch will have to wait a bit, as I am unable to install a suitable |
|
This module is pretty low maintenance. You are the first in a long time to open issues against the file/directory handlers, and you seem eager to do the work so it isn't much more than getting to make the call about which changes go it, with someone else from the hapi core team doing a code review before merging. My guess is that it will stay a pretty low key module. As for 8.0, you can manually link to the -rc1 modules in the shrinkwrap file, or give it a day and an 8.0-rc1 will be published. |
|
@hueniverse I'm in. Where do I sign up? Do you need something else from me? |
|
@kanongil you are now the lead maintainer and all setup on npm and github. |
979a386 to
dee3465
Compare
dee3465 to
b1a0b4e
Compare
|
The patch is no longer WIP, and I would like it to be merged at some point. Any comments on the latest implementation? My main concern is that the open file descriptors can get "lost" and never get closed. Assuming that hapi remembers to call |
Use open file descriptors to retain file between prepare and marshal phases
|
Note that with this change, we now open fd for no reason when using pre-compressed files. I am not too concerned about it as the issue this fixes is more important but it does increase the number of fd created when errors are involved. |
|
This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions. |
WIP patch to fix #4, including new & updated tests.
This patch seems to work as is, and passes all test on my machine. However, it doesn't have 100% code coverage due to never triggering the
Fs.fstat()error response. Given that this is only likely to trigger on messed up filesystems with anEIOerror, I'm at a loss on how to test for this. Perhaps some kind of mocking?I also have concerns about forgetting open file descriptors. I do ensure that they are closed whenever
finishis triggered on the response but I found no such hooks for error'ed responses, which is needed for this to work. Am I missing something?