Context
Following up on #1693 (closed by PR #1736), the new server engine in beta11-rc3 exposes request.body as a ReadableDefaultStream, but the standard Request.text() and Request.json() convenience methods are not implemented.
Current Behavior
export default async function fetch(request: Request): Promise<Response> {
console.log("Has text?", typeof (request as any).text); // undefined
console.log("Has json?", typeof (request as any).json); // undefined
console.log("Body type:", request.body); // ReadableDefaultStream
// This crashes with stack trace:
const text = await request.text();
}
Error when calling request.text():
TypeError: invokeMember (text) on POST http://localhost:8080/ failed due to: Unknown identifier: text
Error when trying to read from request.body stream directly:
JsPromiseImpl.resolve -> ReadableDefaultStream.cleanup -> stack trace crash
Expected Behavior
Per the Fetch API standard, Request should have:
request.text() - Returns promise resolving to body as string
request.json() - Returns promise resolving to parsed JSON
request.arrayBuffer() - Returns promise resolving to ArrayBuffer
request.blob() - Returns promise resolving to Blob
Environment
- Elide version: 1.0.0-beta11-rc3
- Platform: Linux (WSL2)
Workaround Needed
For building HTTP APIs that accept POST bodies (like MCP servers, REST APIs), we need a working way to read request bodies. Currently blocked on this for building the Elide Compatibility Service.
Related
Context
Following up on #1693 (closed by PR #1736), the new server engine in beta11-rc3 exposes
request.bodyas aReadableDefaultStream, but the standardRequest.text()andRequest.json()convenience methods are not implemented.Current Behavior
Error when calling
request.text():Error when trying to read from
request.bodystream directly:Expected Behavior
Per the Fetch API standard,
Requestshould have:request.text()- Returns promise resolving to body as stringrequest.json()- Returns promise resolving to parsed JSONrequest.arrayBuffer()- Returns promise resolving to ArrayBufferrequest.blob()- Returns promise resolving to BlobEnvironment
Workaround Needed
For building HTTP APIs that accept POST bodies (like MCP servers, REST APIs), we need a working way to read request bodies. Currently blocked on this for building the Elide Compatibility Service.
Related