title: Troubleshooting sidebar_position: 11 id: troubleshooting license: | Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
This page covers common Dart issues and fixes.
Only xlang payloads are supported by the Dart implementation.The writer is sending a native-mode payload. Make sure every peer writes the xlang wire format:
Type ... is not registered.Fory does not know how to serialize or deserialize this type. Fix it by:
dart run build_runner build --delete-conflicting-outputsregister function (or registerSerializer) for the type before calling serialize or deserialize.Order contains an Address, register both.Regenerate code:
cd dart/packages/fory dart run build_runner build --delete-conflicting-outputs
If you moved files or renamed types, rebuild before re-running analysis or tests.
Deserialized value has type ..., expected ...The payload describes a different type than T in deserialize<T>. Common causes:
Object? or List<Object?> first, then cast.Fory does not track object identity by default, so two fields pointing to the same object will produce two independent copies after a round trip.
To preserve identity:
@ForyStruct, add @ForyField(ref: true) to those fields.trackRef: true to fory.serialize(...).context.writeRef / context.readRef and call context.reference(obj) before reading nested fields.Symptoms: fields come back as default values or wrong types after a round trip to another language.
Checklist:
name).@ForyField(id: ...) assigned before the first payload was produced.@ForyField(type: Int32Type()) in Dart when the peer field is int (Java), int32 (Go), or int (C#).Timestamp / LocalDate instead of raw DateTime for date/time fields.compatible: false.On Dart VM builds, Dart int can represent signed 64-bit values. On Dart web builds, Dart int values are backed by JavaScript numbers and are only precise inside the JS-safe integer range:
-9007199254740991 <= value <= 9007199254740991
If a generated serializer writes an int64 field declared as Dart int, web builds reject values outside that range instead of silently writing corrupted bytes. To exchange full signed 64-bit values on web, declare the field as Fory's Int64 wrapper:
@ForyStruct() class LedgerEntry { LedgerEntry(); Int64 sequence = Int64(0); // full signed 64-bit range on VM and web }
For unsigned 64-bit values, prefer Uint64 rather than Dart int. Dart int cannot represent the full uint64 range on either VM or web:
@ForyStruct() class FileBlock { FileBlock(); Uint64 offset = Uint64(0); // full unsigned 64-bit range }
@ForyField(type: Int64Type(...)) changes the wire encoding for a Dart int field, but it does not remove the web integer precision limit. Use Int64 for full-range signed values and Uint64 for full-range unsigned values. See Web Platform Support for the full browser support matrix and platform guidance.
Main Dart package:
dart run build_runner build --delete-conflicting-outputs dart analyze dart test
Integration test package:
cd dart/packages/fory-test dart run build_runner build --delete-conflicting-outputs dart test
package:grpc typesCause: gRPC packages are application dependencies. The fory package does not add gRPC as a hard dependency.
Fix: Add grpc to your pubspec.yaml (and the build_runner dev dependency), then run dart pub get. See gRPC Support.
Cause: Fory gRPC companions use gRPC transports with Fory-encoded message bodies, not protobuf wire encoding.
Fix: Use a Fory-generated client for Fory-generated services, or expose a separate protobuf service endpoint for generic protobuf clients.