chaokunyang commented on code in PR #4013:
URL: https://github.com/apache/fory/pull/4013#discussion_r3921571607
##########
javascript/packages/core/lib/gen/index.ts:
##########
@@ -175,6 +175,12 @@ export class Gen {
generateSerializer(typeInfo: TypeInfo) {
this.traversalContainer(typeInfo);
+ if (containerDeclaresElementTypes(typeInfo)) {
+ // The type-id keyed registry only holds the dynamic container
+ // serializer; a container with declared element types gets a dedicated
+ // serializer for this registration.
+ return this.generate(typeInfo);
Review Comment:
Registering the container before its extension codec now leaves the
generated serializer bound to `undefined`, even when all registration finishes
before the first root operation:
```ts
class E {}
Type.ext(901)(E);
const fory = new Fory({ compatible: false });
const list = fory.register(Type.list(Type.ext(901)));
fory.register(E, { write() {}, read() {} });
list.serialize([new E()]);
```
`traversalContainer()` creates forward placeholders for structs but not
extensions, so `ExtSerializerGenerator.writeEmbed()` captures the missing
serializer in a factory-level constant. Registering `E` afterward cannot update
that constant, and serialization fails at `ext_ser.writeTypeInfo(null)`. Sets
have the same issue. The previous dynamic root serializer resolved the codec at
write time.
Please preserve registration ordering before the first operation by ensuring
the generated container binds to the completed extension codec, and add a
regression test for this order.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]