Skip to content

Using a class' name as a key to a serialization adapter causes Seroval to fail #6105

@notKamui

Description

@notKamui

Which project does this relate to?

Start

Describe the bug

The bug is caused by using a class' name as a key for a serialization
adapter instead of a literal string. In this example, see src/IntWrapper.ts,
where the serialization adapter is registered using IntWrapper.name.

The initial suspicion was that the name property could change after bundle
time since the class could be minified or mangled, but after testing by simply
logging the value of IntWrapper.name in various environments (dev, prod)
it consistently printed IntWrapper. This indicates that the class name remains stable
across different builds in this specific case (which is surprising to me).

Using this as a key:

{
  key: (() => {
    console.log(IntWrapper.name);
    return IntWrapper.name;
  })(),
}

yields the error in prod build even though it does log IntWrapper. You would expect
that using the class name as a key would work if it is stable, but apparently
it does not.

Your Example Website or App

https://github.com/notKamui/tss-serialization-adapter-seroval-error

Steps to Reproduce the Bug or Issue

  1. Install the dependencies (preferably using bun to use the present bun.lock, but any should work)
  2. Build (bun run build)
  3. Start the prod server (uses srvx) (bun run start)
  4. Go to http://localhost:3000
  5. Click on the "Go to Sum" link (goes to /sum)
  6. See the error happen (logs on the client and server)
Image
  1. Reload the page at http://localhost:3000/sum to see a different error on the client
Image

Expected behavior

No error should happen, and the serialization should be correct

Screenshots or Videos

Image

Platform

  • Router / Start Version: 1.141.2
  • OS: Any (tested on macOS, Windows)
  • Browser: Arc (Chromium)
  • Browser Version: Chromium Engine Version 141.0.7390.55
  • Bundler: Vite
  • Bundler Version: 7.3.0

Additional context

No response

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