Skip to content

Commit

Permalink
Fix crash when collecting the body (#2992)
Browse files Browse the repository at this point in the history
Run the body collect on the event loop to ensure there are no concurrency issues
  • Loading branch information
0xTim committed Apr 11, 2023
1 parent b1be620 commit 00bd82b
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Sources/Vapor/Concurrency/RoutesBuilder+Concurrency.swift
Expand Up @@ -128,7 +128,9 @@ extension RoutesBuilder {
{
let responder = AsyncBasicResponder { request in
if case .collect(let max) = body, request.body.data == nil {
_ = try await request.body.collect(max: max?.value ?? request.application.routes.defaultMaxBodySize.value).get()
_ = try await request.eventLoop.flatSubmit {
request.body.collect(max: max?.value ?? request.application.routes.defaultMaxBodySize.value)
}.get()

}
return try await closure(request).encodeResponse(for: request)
Expand Down

0 comments on commit 00bd82b

Please sign in to comment.