Skip to content

rpc: RPC over HTTP puts long string arguments in the URL, which fails #768

Open

Description

@lionelhorn

The HTTP client sends an action whose arguments are all primitives as GET, with the arguments in the URL, whatever their length. A 20,000-character string already fails; the same text inside an object (sent as POST) works. Over WebSocket all three calls work.

import { App } from '@deepkit/app';
import { ApplicationServer, FrameworkModule } from '@deepkit/framework';
import { rpc, RpcClient, RpcHttpClientAdapter } from '@deepkit/rpc';

@rpc.controller('docs')
class DocController {
    @rpc.action()
    save(markdown: string): number {
        return markdown.length;
    }

    @rpc.action()
    saveNote(note: { markdown: string }): number {
        return note.markdown.length;
    }
}

const app = new App({
    controllers: [DocController],
    imports: [new FrameworkModule({ port: 8080, httpRpcBasePath: '/api' })],
});
await app.get(ApplicationServer).start();

const docs = new RpcClient(new RpcHttpClientAdapter('http://127.0.0.1:8080/api')).controller<DocController>('docs');
console.log(await docs.save('x'.repeat(20_000)).catch((error: Error) => error.message));
// actual: Unexpected end of JSON input, should be: 20000
console.log(await docs.save('x'.repeat(100_000)).catch((error: Error) => error.message));
// actual: fetch failed, should be: 100000
console.log(await docs.saveNote({ markdown: 'x'.repeat(100_000) }));
// 100000

Master 0bb9fba, Node 26.13.0.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions