remix-run / remix

Build Better Websites. Create modern, resilient user experiences with web fundamentals.
https://remix.run
MIT License
29.32k stars 2.47k forks source link

Submitting empty `Form` on chrome throws error #6507

Closed akamfoad closed 1 year ago

akamfoad commented 1 year ago

What version of Remix are you using?

1.16.1

Are all your remix dependencies & dev-dependencies using the same version?

Steps to Reproduce

  1. Create a Remix App
  2. Create a form with no input but a submit button
  3. click the submit button

Or you can see this reproduction app.

Notice when the checkbox is checked submitting works fine, but when its unchecked, it fails to submit and crashes.

This only happens on Chrome, it works fine on Firefox.

Also using form.submit still works, form.requestSubmit or normal submit causes the crash to happen.

Expected Behavior

To submit the form and send the request to the action regardless of what browser I use.

Actual Behavior

The Form crashes with this error stack

TypeError: Failed to fetch
    at fetchData (https://remixrunremixphwauf-t1s0--3000--272d3407.local-credentialless.webcontainer.io/build/_shared/chunk-Q6KF7EY5.js:10638:139)
    at https://remixrunremixphwauf-t1s0--3000--272d3407.local-credentialless.webcontainer.io/build/_shared/chunk-Q6KF7EY5.js:10857:26
    at runHandler (https://remixrunremixphwauf-t1s0--3000--272d3407.local-credentialless.webcontainer.io/build/_shared/chunk-Q6KF7EY5.js:5992:26)
    at callLoaderOrAction (https://remixrunremixphwauf-t1s0--3000--272d3407.local-credentialless.webcontainer.io/build/_shared/chunk-Q6KF7EY5.js:6031:22)
    at handleAction (https://remixrunremixphwauf-t1s0--3000--272d3407.local-credentialless.webcontainer.io/build/_shared/chunk-Q6KF7EY5.js:5016:22)
    at startNavigation (https://remixrunremixphwauf-t1s0--3000--272d3407.local-credentialless.webcontainer.io/build/_shared/chunk-Q6KF7EY5.js:4960:32)
    at Object.navigate (https://remixrunremixphwauf-t1s0--3000--272d3407.local-credentialless.webcontainer.io/build/_shared/chunk-Q6KF7EY5.js:4890:18)
    at https://remixrunremixphwauf-t1s0--3000--272d3407.local-credentialless.webcontainer.io/build/_shared/chunk-Q6KF7EY5.js:8058:15
    at submitHandler (https://remixrunremixphwauf-t1s0--3000--272d3407.local-credentialless.webcontainer.io/build/_shared/chunk-Q6KF7EY5.js:8438:9)
    at HTMLUnknownElement.callCallback2 (https://remixrunremixphwauf-t1s0--3000--272d3407.local-credentialless.webcontainer.io/build/entry.client-5PJUSWK4.js:3695:22)
brophdawg11 commented 1 year ago

Hm, this seems like maybe a bug in Chrome? When creating a new Request with an empty FormData instance as the body, you can await request.text() but it throws an error on await request.formData():

Screenshot 2023-05-30 at 10 21 02 AM

It seems fine in Firefox:

Screenshot 2023-05-30 at 10 22 15 AM
giovannibenussi commented 1 year ago

I have the exact same issue that @brophdawg11 reported on Chrome. I filled a bug report on the Chromium project to see if we can get help from them: https://bugs.chromium.org/p/chromium/issues/detail?id=1450115

brophdawg11 commented 1 year ago

🙌 Thank you for filing that @giovannibenussi!

brophdawg11 commented 1 year ago

I am going to close this out since it seems like the Chrome team is open to fixing on their end.