-
Notifications
You must be signed in to change notification settings - Fork 0
Prevent 503's on attachment uploads #709
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,7 @@ | |
| package lucuma.odb.graphql | ||
|
|
||
| import cats.effect._ | ||
| import cats.effect.implicits._ | ||
| import cats.effect.std.UUIDGen | ||
| import cats.implicits._ | ||
| import eu.timepit.refined.types.string.NonEmptyString | ||
|
|
@@ -97,6 +98,7 @@ object ObsAttachmentRoutes { | |
| s | ||
| .insertAttachment(user, programId, typeTag, fileName, description, req.body) | ||
| .flatMap(id => Ok(id.toString)) | ||
| .guarantee(req.body.compile.drain) | ||
| .recoverWith { | ||
| case EntityLimiter.EntityTooLarge(_) => | ||
| BadRequest(s"File too large. Limit of $maxUploadMb MB") | ||
|
|
@@ -113,6 +115,7 @@ object ObsAttachmentRoutes { | |
| s | ||
| .updateAttachment(user, programId, attachmentId, fileName, description, req.body) | ||
| .flatMap(_ => Ok()) | ||
| .guarantee(req.body.compile.drain) | ||
| .recoverWith { | ||
| case EntityLimiter.EntityTooLarge(_) => | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I recently fixed a bug in the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Interesting. It seems to have been working. Of course on Heroku we just got a 503. |
||
| BadRequest(s"File too large. Limit of $maxUploadMb MB") | ||
|
|
||
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.
What are the unforeseen consequences of always draining the stream regardless of whether it has already been fully or partially read? In some local tests with a 3+M file that was successfully uploaded, a
compile.toListwhere thecompile.drainis was reading values of <64K bytes.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.
Ugh this is a really good question. I'm not sure it is well-specified, it may be implementation specific, and I have to take a look.
Are we currently using Blaze server? Do you think we can switch to Ember?
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 have no problem switching to Ember, but I think I remember @tpolecat saying something about Ember vs Blaze so we should check with him.
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.
Ember was broken last time I tried it but you could give it a try. I would like to get off Blaze.
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.
One or more of the Armans have probably fixed it by now.
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.
Yeah at this point I'm making any remaining Ember bugs high priority. In the cutting-edge benchmarks its pulled ahead of Blaze.
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.
Do you want to switch in a separate PR?
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.
Yeah I can work on that. While I do it I will also double-check (and fix if needed) Ember's behavior in this situation.
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 could do the switch to ember if you want to look at the implementation.
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.
Actually, on my attempt I keep getting these
So I'm probably missing something...