-
Notifications
You must be signed in to change notification settings - Fork 170
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
FormatRegistry throws error TypeSystemDuplicateFormat in Hermes engine #1049
Comments
@BleedingDev Hi, Duplicate format exceptions may result from modules being unintentionally loaded multiple times, or there is logic explicitly trying to set the format. Originally, the intention for TypeSystem was to try and enforce a single point of registration, however in practice, there are cases where repeated initialization may be a consequence of module initialization issues (tooling related) or a preference for using idempotent design patterns with respect to registration (this of course is perfectly valid) Outside of repeated module loading issues (that would need to be reported elsewhere), you can actually replace import { TypeRegistry, FormatRegistry } from '@sinclair/typebox'
FormatRegistry.Set('date', value => { /** code to check date */ }) By calling these directly, you avoid any issues with duplicate registration. Hope this helps |
@BleedingDev Hiya, Will close off this issue for now as things should be working ok if you assign formats directly on the FormatRegistry. If you run into any problems, happy to re-open the issue, but this should resolve things for you. Cheers |
I don't even use Typebox directly, nor register anything. What I was trying to do is import ElysiaJS into React Native, so that I could use Eden to make type-safe calls. :) |
@BleedingDev Hi, Ah. It might be worth pinging the downstream projects to investigate registering formats via the FormatRegistry instead of the TypeSystem.Format function. Unfortunately, I can't trivially change the duplicate format check on the TypeSystem.Format function without that change being breaking, but the issue can be resolved downstream by registering via the FormatRegistry instead (as it applies no check for duplicate registrations) There's been a couple of cases where I've seen module systems are violating singleton module instancing rules. I don't know much about the Hermes engine, but it may be doing this which is why you see the error. The TypeSystem.Format function expects systems to respect singleton instancing, but it is possible this assumption may not be applicable everywhere. Hope this helps |
I use React Native and Hermes engine and this particular line throws an error:
typebox/src/system/system.ts
Line 62 in ac90038
I don't use anything special and when I delete this line, it fixes the problem.
Otherwise I get this error:
I found that it might be problem with Hermes as well, so if you suggest it should go there, I'll report it there.
The text was updated successfully, but these errors were encountered: