Skip to content

rpc: strictSerialization(false) is ignored over HTTP #771

Open

Description

@lionelhorn

strictSerialization(false) is documented as "No validation is performed", and over WebSocket an argument of another type is accepted. Over RpcHttpClientAdapter the arguments are still converted to the declared types and the call fails with a validation error.

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

interface Event {
    name: string;
    at: number;
}

@rpc.controller('legacy')
class LegacyController {
    @rpc.action().strictSerialization(false)
    track(event: Event): string {
        return `${event.name} ${typeof event.at} ${event.at}`;
    }
}

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

// an older client, built when `at` was still a date string
type OldEvent = { name: string; at: string };
type OldLegacyController = { track(event: OldEvent): string };
const legacy = new RpcClient(new RpcHttpClientAdapter('http://127.0.0.1:8080/api')).controller<OldLegacyController>('legacy');
console.log(await legacy.track({ name: 'login', at: '2026-01-01' }).catch((error: Error) => error.message));
// actual: 'Validation error:\nevent.at(type): Cannot convert 2026-01-01 to number'
// should be: 'login string 2026-01-01' (as over WebSocket)

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