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

Pending multipart request with angular rxjs #3220

Open
jonatansalemes opened this issue Dec 12, 2023 · 1 comment · May be fixed by #3221
Open

Pending multipart request with angular rxjs #3220

jonatansalemes opened this issue Dec 12, 2023 · 1 comment · May be fixed by #3221
Labels
A-http project: actix-http C-bug Category: bug

Comments

@jonatansalemes
Copy link

jonatansalemes commented Dec 12, 2023

i`m facing a very strange issue when i have multipart endpoints in actix using angular app (rxjs client):

actix endpoint

#[post("/mt")]
pub async fn service(payload: Multipart) -> Result<impl Responder, Error> {
    if true {
        let bad_request =
            HttpResponse::BadRequest().json(BadRequestError(BadRequestErrorResponse {
                message: "You don't have enough balance".to_string(),
            }));
        return Ok(bad_request);
    }

    Ok(HttpResponse::Ok().json("ss"))
}

angular http client request

    createNew(f1: File, f2: File) {
        const apiUrl = this.appConfig.apiUrl;
        const formData = new FormData();
        formData.set('f1', f1, f1.name);
        formData.set('f2', f2, f2.name);
        return this.httpClient
            .post<CreateNewSwapResponse>(`${apiUrl}/mt`, formData);
    }

after first bad request, the next request get in pending status forever in network tab.

i have switched to spring boot endpoint, that works nice without pending behaviour, to check headers difference. So spring after bad request send header

[only header, not closing server socket]
Connection: close

actix does not sent nothing, after explore actix source code

image

i have, just for test, force connection close on encoder.rs even is keep alive was sent by client and stop hanging pending request in client after that. There is some way to add feature like force_close_header only ? because i have tryied force_close but this close socket generating error. Another idea maybe is respect if add_header(("Connection", "close")) was added instead use connection type to write connection header. Some idea ? i can write a pull request if need it.

@jonatansalemes jonatansalemes linked a pull request Dec 12, 2023 that will close this issue
5 tasks
@kvzn
Copy link

kvzn commented Dec 25, 2023

Got the same issue, thank you for your fixing, hope the PR be merged asap.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-http project: actix-http C-bug Category: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants