You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@fory.apache.org by "Sarthak-Pandey (via GitHub)" <gi...@apache.org> on 2026/10/04 17:45:49 UTC

[I] Enforce registration freeze after first root serialize/deserialize operation [fory]

Sarthak-Pandey opened a new issue, #4118:
URL: https://github.com/apache/fory/issues/4118

   ### Search before asking
   
   - [x] I had searched in the [issues](https://github.com/apache/fory/issues) and found no similar issues.
   
   
   ### Version
   
   Fory: main branch
   Commit: 34890aed7
   
   OS: Windows 11
   Python: 3.13.14
   Node.js: 22.14.0
   Go: go1.24.5
   .NET: 9.0.203
   
   ### Component(s)
   
   Go
   
   ### Minimal reproduce step
   
   ### Steps to reproduce
   
   1. Create a new Fory instance.
   2. Perform a root serialization operation.
   3. Attempt to register another struct after serialization.
   4. Check whether the registration is rejected.
   
   Example:
   
   ```go
   package main
   
   import (
   	"fmt"
   
   	"github.com/apache/fory/go/fory"
   )
   
   type Item struct {
   	Count int32
   }
   
   type Late struct {
   	Name string
   }
   
   func main() {
   	f := fory.New()
   
   	// First root operation.
   	_, err := f.Serialize(Item{Count: 1})
   	if err != nil {
   		panic(err)
   	}
   
   	// Registration after the first root operation.
   	err = f.RegisterStruct(Late{}, 101)
   
   	fmt.Println("registration error:", err)
   }
   
   ### What did you expect to see?
   
   After the first root `serialize()` or `deserialize()` operation starts, the Fory instance should be permanently frozen for registration.
   
   Any subsequent attempt to register a new type, struct, serializer, enum, or union should fail immediately with an appropriate error.
   
   The failed registration should not modify the resolver maps, serializers, metadata, descriptors, or caches.
   
   This behavior should be consistent across all Fory language runtimes.
   
   ### What did you see instead?
   
   The Fory instance appears to remain mutable after the first root
   `serialize()` or `deserialize()` operation.
   
   In the affected runtimes, a type or serializer can be registered after the
   instance has already been used, instead of the registration being rejected.
   
   This is inconsistent with the expected registration lifecycle and can be
   particularly problematic when a Fory instance is shared by concurrent
   workers, because one operation may read resolver state while another
   operation modifies it.
   
   The affected runtimes identified are Go, Python, C#, and JavaScript.
   
   ### Anything Else?
   
   _No response_
   
   ### Are you willing to submit a PR?
   
   - [x] I'm willing to submit a PR!


-- 
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: commits-unsubscribe@fory.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@fory.apache.org
For additional commands, e-mail: commits-help@fory.apache.org


Re: [I] Enforce registration freeze after first root serialize/deserialize operation [fory]

Posted by "chaokunyang (via GitHub)" <gi...@apache.org>.
chaokunyang closed issue #4118: Enforce registration freeze after first root serialize/deserialize operation
URL: https://github.com/apache/fory/issues/4118


-- 
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: commits-unsubscribe@fory.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@fory.apache.org
For additional commands, e-mail: commits-help@fory.apache.org