Which file are you referring to?
Thread Starter
Lukasz
(@wpfed)
The HTTP response status codes 200-299 are successful responses, not errors.
Hi,
If you look closely at the code you pointed out, responses in the 200 range are explicitly returned, while anything outside of that range is thrown as an error.
The minified version can be a bit hard to read, but you can see the original, unminified source here:
https://github.com/rocklobster-in/contact-form-7/blob/master/includes/js/src/api-fetch.js#L74-L80
From reading this source, it appears to be behaving as intended: non-2xx responses are treated as errors and rejected, rather than handled as successful responses.
In addition, apiFetch is caught at the call site.
You can see this in submit.js here:
https://github.com/rocklobster-in/contact-form-7/blob/80a7d78b4a0586437f4b8e15df65d56558b4a050/includes/js/src/submit.js#L90
At that point, errors outside the 200 range are handled and the error output is triggered.
Given this flow, the form should not remain in a “loading” state when a 4xx or 5xx response is returned.
Based on this, it seems unlikely that Contact Form 7 is “not handling” 400–500 level errors.
If the spinner remains visible, it may be worth checking whether the request is actually completing, or whether another JavaScript error or optimization/minification step is interfering with the error handling.
Best regards
Thread Starter
Lukasz
(@wpfed)
Thanks @takayukister and @ytsuyuzaki ! , I wrote that in haste, I meant the successful status codes 200 range are handled but http 400-500 codes are causing the form to hang(which is my real issue).
Based on what @ytsuyuzaki mentioned I will investigate on a fresh install on my server to see how it behaves since I do have alot of custom code that may be interfering with how those errors are handled.
Hi Lukasz,
I’m glad my explanation helped point you in a useful direction.
I hope you’re able to identify the cause during your testing and get everything working smoothly.
Wishing you all the best with your site.
Contact Form 7 rethrows 400-599 error responses and lets the browser handle them (so the form will appear to hang). This itself is absolutely an intended behavior.
Thread Starter
Lukasz
(@wpfed)
Thank you guys, I tried on Fresh install, I simulated some errors by breaking smtp config or uploading very large file size attachment(50MB+). Large file did cause the hanging, form was stuck in submitting status with error in console and no user error message: “413 Content Too Large”
But it worked worked much better for second scenario with broken/failed smtp server, it showed user error, so I do have issue in my code, I will investigate that, the other error 413 is not a concern.
Thank you guys, appreciate you!