-
-
Notifications
You must be signed in to change notification settings - Fork 133
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
Allow the same data to be shared by multiple Upload scalars #92
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's great news 🎉
Does this mean the Deduped files
test should no longer be todo?
Also, a changelog entry should be added under ## Next
.
That's correct! I just hadn't finished the implementation; the first commit was simply to ensure existing functionality with the new API for fs-capacitor, but then I got tired and went to bed :). This should now support file de-dup. If you wouldn't mind just giving a quick scan of fs-capacitor (master branch) to make sure everything there looks sane, I'll publish it as |
OK, so the challenge here is timing our cleanup... What we need to do is:
We want to do this once we know that the server is done, which we can assume is true once the response is sent. Initially, I attempted to do this when the request closed, but node 8 doesn't fire this event in the same situations as node 10. I had to do all sorts of trial and error to get #81 to work the same across the different versions, and I suspect I'll have to do so here as well. I'm going to have to shelve this for another day. |
mike-marcacci/fs-capacitor#1 is fixed in v1.0.0-beta.3
OK, so this should now pass in all versions of node >=8. However, I did resort to some unattractive behavior in order to get this to work without making breaking changes to Instead, I would prefer either:
@jaydenseric do you have any thoughts about making these changes? |
In fact, I'm pretty sure we should make one of these changes to the API; right now there's a "hidden" breaking change, in that the API will continue to work, but could leak files (until the process exits)... which is the worst kind of breaking change. |
OK, so the real challenge I'm facing here is in timing (surprise, surprise). In particular, the existing behavior says that in the following scenario:
It should be possible to call Is this an OK change to make? I believe I can keep the previous behavior, but the API change would be different: the middleware would have to call release when all resolvers are finished, instead of |
Is it possible to have it so that cleanup will not happen before the HTTP request/response is closed ( |
Hey @jaydenseric that is the current behavior in this PR :) |
I have another hour here and I get to figure out why it's hanging on travis... since the tests pass every time in a while loop on mac... |
You can run Travis locally in a Docker image, I found it helpfull when I had some things work locally but not in Travis. You can temporarily undo all the async config for tests too, so they at least log progress up until the point of failure instead of silently hanging. |
OK! So I've got this working. I kept getting throttled at this coffee shop while downloading the travis docker images (great tip btw!) but I already had some linux node images on my machine which helped me narrow down the timing issue. I've simplified the error handling so that all "fatal" errors use the I also consolidated In the abort test, I do use a This ended up being a much smaller change with our new strategy of calling |
src/middleware.mjs
Outdated
|
||
if (map) | ||
for (const upload of map.values()) | ||
if (upload.file) upload.file.capacitor.destroy() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought capacitor
was only going to be used in tests?
Holy moley the tests have become complicated. There has to be a simpler, more consistent way to approach some of them 🤔 |
Hey! Sorry for the delay; was away from sufficient connectivity for longer than I had anticipated. In my first implementation (before I realized I needed the I completely agree about the tests and definitely like your changes. We can probably just check the |
This will provide support for file deduplication using alpha releases of fs-capacitor which I'm building alongside this.
The fs-capacitor API needed to change to accomplish this, so I went ahead and added tests and better docs (borrowing a lot of boilerplate from this project, since this will probably be its primary use case).