Add json(), text() and other missing methods to JsRequest - #5341
Conversation
Test262 conformance changes
Tested main commit: |
b690a67 to
30715ff
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5341 +/- ##
===========================================
+ Coverage 47.24% 62.90% +15.66%
===========================================
Files 476 530 +54
Lines 46892 59148 +12256
===========================================
+ Hits 22154 37207 +15053
+ Misses 24738 21941 -2797 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
I don't think this is the correct approach to enable fetching the body of a request. From what I investigated, |
| /// duplicating or double-reading it. | ||
| #[unsafe_ignore_trace] | ||
| body: Rc<RefCell<BodyState>>, |
There was a problem hiding this comment.
Also this will leak, because BodyState could be a future with Gc'd objects in it, making it possible to leak objects using this since the GC won't trace through the body.
|
The responsibility of fetching the body should be lifted to the |
The JS-facing body getter returning a proper
The concern is technically valid at the type level, |
Then we are just implementing something that will be removed in the future, right? Seems like a waste to hack around this instead of offering a proper API for readable streams.
We generally don't assume how users interact with APIs, because we have seen so many weird usages that we just go with the safest option. Leaking here is not the safest option. |
|
Adding Ad Gc object leak: |
Uh not really. Offering a
That does not work, because Rust does not understand the concept of implementing |
|
I did not propose passing async blocks but an implementation of |
Are you suggesting that we force every user to manually implement
Not necessarily. We have an API to convert a Future into a JsPromise, so users can just enqueue an async job that eventually resolves a promise without having to deal with storing |
|
It seems that |
This is safe because the input async closure is never unrooted to store it into a JsObject; the future is resolved at the |
|
I've been looking at the GC internals and I believe both approaches have the same leak properties: any The one difference I can see is that a future stored inside a |
|
|
Since the async-body mechanism was rejected, I am narrowing this PR to the getters as the PR title describes. |
Adds request methods
method,url,headers, and allows reading the request body withtext,json,form_data. Host can supply the body asynchronously.