-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Named Form Action executes twice and fails with TypeError: The body has already been consumed.
for await request.formData()
#11663
Comments
TypeError: The body has already been consumed.
for await request.formData()
TypeError: The body has already been consumed.
for await request.formData()
I have tried the following:
|
Please provide a working minimal reproduction that reproduces the issue. |
#11870 just fixed most of the reported issues with invalidation, so can you test to see if you're still having issues with 2.5.1? |
Hi @benmccann I updated the SvelteKit version but still facing the same issue |
Thank you so much to @fehnomenal who help me fix my issue. It was a bug in my I am using a This caused the requests to be done one after another. I am not sure how does it work internally, but adding an await for my More details are here: #6800 (comment) |
Describe the bug
I am using a named action on the route
/connections/new
which has a form with action?/getAuthURL
.The method:
This is the
+page.svelte
codeI have used the VSCode Javascript Debug Terminal to go step through each line of the method in
+page.server.ts
when I "Submit" the form from+page.svelte
.The request comes through properly and goes through my
hooks.server.ts
smoothly. It executes theconst values = await request.formData();
and generates thevalues
correctly. It goes till the end of the method perfectly and even populatesurlToRespond
.I made sure by checking the
request.bodyUsed
function is ONLY BEING SET when we read theawait request.formData()
in the first line.BUT THEN weirdly, after the last line, the flow of the program JUMPS backs to the first line, to
const values = await request.formData();
, where it tries to read formData again and then fails withTypeError: The body has already been consumed.
I made sure that there was no recursion in the program and there weren't MULTIPLE requests coming from the client side as well.
??? What the hell is happening? how is the control of flow jumping back to the start of the method??
Workaround
The following feels unnecessary and is not the cleanest way, but cloning the request worked.
However while stepping through the function with a debugger, I saw the named action method got executed twice
Reproduction
I have tried to simulate it here
But i am not able to reproduce it.
Here are screenshots to show the method block executing successfully from 1st line to last and then erratically jumping back to the first line.
1st time hitting the submit function:
Successfully going to the last line of the method and populating the
urlToRespond
variableBut then going back to the first line and RESETTING all the local variables??????
and then the failure
Logs
The text was updated successfully, but these errors were encountered: