You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note: This is not a nitropack bug because the fault lies with the utilities provided by h3.
It is possible to create a workaround using different h3 functions, therefor the failing function is faulty.
Reproduction
Create a nitro project, add a route containing the following handler:
That said, I do know that toWebRequest() is the function within readFormData that is at fault.
The event.node.req.body field is a string containing the POST body of the request before calling into readFormData.
Using the following implementation of readFormData can succesfully read the data:
Here readRawBody short-circuits because event.node.req.body is set and RequestInit.body is allowed to be of type string.
Logs
Logging statements directly before `await readFormData(...)` show up in netlify's function log.Logging statements directly after `await readFormData(...)` do not.
The text was updated successfully, but these errors were encountered:
Looking at getRequestWebStream, it uses the event's stream without checking that it still has data left to read.
At the time of crashing (as in, just before calling the function). The stream has some properties indicating it is done:
readableEnded is true
readable is false
complete is true
Perhaps getRequestWebStream could be changed to feed the from event.node.req.data back to the server if it has already arrived.
passionate-bram
changed the title
Utility toWebRequest does not respect event.node.req.body
Utility toWebRequest crashes server when body has already been received.
Nov 20, 2023
passionate-bram
changed the title
Utility toWebRequest crashes server when body has already been received.
Utility toWebRequest crashes server when body has already been received
Nov 20, 2023
Environment
nodejs:18.v18
.Note: This is not a nitropack bug because the fault lies with the utilities provided by h3.
It is possible to create a workaround using different h3 functions, therefor the failing function is faulty.
Reproduction
Locally, you get what you expect:
Describe the bug
Using
readFormData
crashes the server, not even allowing an error to be caught withcatch
or similar mechanisms.I cannot see exactly why the server crashes, as I only receive a cryptic error back:
Additional context
Root cause of nitrojs/nitro#1721
That said, I do know that
toWebRequest()
is the function withinreadFormData
that is at fault.The
event.node.req.body
field is a string containing the POST body of the request before calling intoreadFormData
.Using the following implementation of
readFormData
can succesfully read the data:Here
readRawBody
short-circuits becauseevent.node.req.body
is set andRequestInit.body
is allowed to be of type string.Logs
The text was updated successfully, but these errors were encountered: