-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Companion: Use GET instead of HEAD for getURLMeta + Cut off length of file names #3048
Conversation
Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
and abort request immediately upon response headers received #3034 (comment)
or else we get "MetadataTooLarge: Your metadata headers exceed the maximum allowed metadata size" in tus / S3
I have now completely changed strategy in this PR: 1. Change
|
Not sure the async/await improves the readability here, given the fact that's only one |
IMO the advantages of async/await are:
|
I agree that sequential code is easier to read, but I don't think it applies here: The previous code was not using a callback API, but a Promise one. Also it was sequential, and wasn't using an IIFE. Counter proposal: make the |
the previous code did indeed have a callback, inside .then:
I think avoiding nesting is generally preferrable, but I agree that in this case the added IIFE also gives more nesting so my change doesn't give much advantage.
Agree. I'm just so used to using express-async-handler with express, and in that case any async rejections will be caught automatically and responded.
Good idea, I'll do that. |
expect(time).toBeGreaterThanOrEqual(50) | ||
expect(time).toBeLessThan(100) | ||
expect(time).toBeGreaterThanOrEqual(30) | ||
expect(time).toBeLessThan(70) |
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.
tbh using Date
API is probably not a great idea for this kind of tests, it could use a refactor to performance.now()
. But a change for another time, it should not block this PR.
… file names (transloadit#3048) * rewrite to async/await * Only fetch size (HEAD) if needed transloadit#3034 * Update packages/@uppy/companion/src/server/controllers/url.js Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com> * Change HEAD to GET in getURLMeta and abort request immediately upon response headers received transloadit#3034 (comment) * fix lint * fix lint * cut off length of file names or else we get "MetadataTooLarge: Your metadata headers exceed the maximum allowed metadata size" in tus / S3 * try to fix flaky test * remove iife and cleanup code a bit * fix lint by reordering code Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
Fixes #3034
also rewrite to async/await