Skip to content

HTTP Server: Request.text() and Request.json() not implemented in beta11-rc3 #1805

@akapug

Description

@akapug

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    api:nodeNode API and stdlibjavascriptFeatures and issues relating to JSmodule:serverModules, changes, and issues relating to Elide for servers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions