-
Notifications
You must be signed in to change notification settings - Fork 31
Open
Labels
api:nodeNode API and stdlibNode API and stdlibjavascriptFeatures and issues relating to JSFeatures and issues relating to JSmodule:serverModules, changes, and issues relating to Elide for serversModules, changes, and issues relating to Elide for servers
Description
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 stringrequest.json()- Returns promise resolving to parsed JSONrequest.arrayBuffer()- Returns promise resolving to ArrayBufferrequest.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
- HTTP Server: Request body and query parameter parsing issues in JavaScript #1693 (original issue, closed by PR feat: new server engine #1736)
- PR feat: new server engine #1736 (feat: new server engine)
Metadata
Metadata
Assignees
Labels
api:nodeNode API and stdlibNode API and stdlibjavascriptFeatures and issues relating to JSFeatures and issues relating to JSmodule:serverModules, changes, and issues relating to Elide for serversModules, changes, and issues relating to Elide for servers