Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Process Manager state serialization breaks when using a custom TypeProvider with the JsonSerializer #538

Open
jvantuyl opened this issue Aug 22, 2023 · 0 comments

Comments

@jvantuyl
Copy link

jvantuyl commented Aug 22, 2023

Summary

Process Managers don't serialize their state like anything else. This breaks some assumptions about how the serializer and type providers interact. It happens to work with the default config, but breaks with almost any custom TypeProvider implementation.

Description

For aggregates, the source_type for serializing snapshots is taken from the TypeProvider here.

For events, the source_type for serializing snapshots is taken from the TypeProvider here.

This is all well and good. However, for process managers the source_type for serializing snapshots is hardcoded to use the module name here.

That becomes problematic when you're using a custom TypeProvider together with the default JsonSerializer implementation. That's because it tries to look up the type from the TypeProvider here.

So long as you don't use the JSON serializer or don't use a custom TypeProvider, that works fine. When you use both, you get some really exciting errors in serialization.

Recommended Fix

Use the TypeProvider to resolve the type for serializing process managers.

I don't think this will break any existing installations as they're either not encountering it, currently broken anyways, or have worked around it in a way that won't break.

Our Current Issue

We're using OnePiece.Commanded.TypeProvider (see here) to combine type providers from all of our domains. It lets us explicitly specify the names used to reference types. We use the prefix feature as well, which automatically adds a prefix to the names for all of the registered types in a given individual domain.

This is nice because it decouples the database type names from actual module names and, consequently, how our code is structured. Since events are forever, we consider this a pretty big deal. There's no cleaning up the naming later without some database surgery that we'd prefer not to do.

This bug forces us to not register a "decoupled" name and to not use the prefix feature for any process manager. Using prefixes also changes the name even if we use the module name, so we end up having them all collecting in our top-level type provider.

So they cannot go where we normally put them, they cannot be named how we normally name them, and they cannot be decoupled from the module name. As you might imagine, some nervousness about even using process managers at all since we can't later rename modules like we can with aggregates and events.

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

No branches or pull requests

1 participant