-
Notifications
You must be signed in to change notification settings - Fork 509
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
fix: use global scope for metadata storage #928
Comments
Simple fix in storage.ts const globalRef = global as any
export const defaultMetadataStorage = global.classTransformerMetadataStorage
|| (global.classTransformerMetadataStorage = new MetadataStorage()); We are all waiting your new release with the fix!) |
This is still not fixed. |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Description
Currently, the type metadata are cached in
MetadataStorage
which is createdsrc/storage.ts
and exported. As long as this file is imported once, it works as intended. When importing (requiring) file, Node.js looks it up in the import cache so that the every file is not imported only once. This however relies on consistent file names and has some caveats as covered in the documentation. For instance file case sensitiveness or using symlinks inside node_modules. This behavior can lead to having more than one instance ofMetadataStorage
and failing to resolve the correct data types, consequently spitting up random errors.Expected behavior
I expect class-transformer not to rely on importing logic. And creating a singleton storage.
Actual behavior
Singleton is not a true singleton and importing from symlinked locations causes it to create multiple instances.
The text was updated successfully, but these errors were encountered: