Skip to content
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

Large, streamed request body may result in noSignalReceived preconditionFailure crash #3153

Open
daveanderson opened this issue Feb 14, 2024 · 6 comments
Labels
bug Something isn't working

Comments

@daveanderson
Copy link

daveanderson commented Feb 14, 2024

Describe the bug

When streaming a large (20+ MB) request body to a controller that writes it to a file on disk the Request.Body.AsyncSequenceDelegate method produceMore0() encounters a noSignalReceived case and the server exits with a preconditionFailure().

Having the server spontaneously exit in production is highly undesirable.

It's not completely clear why noSignalReceived is occurring, but experimentally replacing the preconditionFailure() with break appears to allow the server to wait for additional data to arrive from the client, allowing the remainder of the body to be received and stored.

Please consider adjusting the implementation of the Request.Body.AsyncSequenceDelegate method produceMore0() such that the server will not spontaneously terminate when streaming a large request body.

To Reproduce

Steps to reproduce the behavior:

  1. A route with configured with body: .stream
  2. A controller method that handles the 20+ MB streamed body using the for try await byteBuffer in body {} pattern.
  3. As the streamed bytes are received at some point the Request.Body.AsyncSequenceDelegate method produceMore0() encounters a noSignalReceived case and the server exits with a preconditionFailure().

Environment

  • Vapor Framework version: 4.92.2
@daveanderson daveanderson added the bug Something isn't working label Feb 14, 2024
@grahamburgsma
Copy link
Contributor

Please test with v4.92.3 https://github.com/vapor/vapor/releases/tag/4.92.3

@0xTim
Copy link
Member

0xTim commented Feb 14, 2024

Hmm if it's hitting https://github.com/vapor/vapor/blob/main/Sources/Vapor/Concurrency/RequestBody%2BConcurrency.swift#L34 then I don't think the latest release will help. It could be the same bug as #2985

@0xTim 0xTim closed this as completed Feb 14, 2024
@0xTim 0xTim reopened this Feb 14, 2024
@0xTim
Copy link
Member

0xTim commented Feb 14, 2024

(Wrong button!)

@grahamburgsma
Copy link
Contributor

@0xTim This PR mentions it fixes this issue in the description: #2998

@daveanderson
Copy link
Author

Vapor v4.92.3 does not resolve the produceMore0() preconditionFailure().

@daveanderson
Copy link
Author

Also, this does appear to be a the same issue as #2985

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants