Async routes that have a body always exhibit thread-unsafety
weissi opened this issue · 0 comments
weissi commented
Vapor's Request
is not thread safe which means that nothing must call request.<anything>
unless you're guaranteed to be on request.eventLoop
already (until #2951 is fixed).
But Vapor's own async code doesn't respect that rule.
For example this code here
needs to be
if case .collect(let max) = body, request.body.data == nil {
try await request.eventLoop.flatSubmit {
request.body.collect(max: max?.value ?? request.application.routes.defaultMaxBodySize.value)
}.get()
}
Obviously the above suggestion is just bandaid, Request
has to become thread safe for it to be viable to use the async support.