-
-
Notifications
You must be signed in to change notification settings - Fork 754
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
[@feathersjs/schema] schema
function is not pure and crashes in ES Modules
#2681
Comments
I would see how AJV does this since the error is coming from there. We could work around it but I'm pretty sure someone needed to do hot module reloading with AJV before. |
I've ruled out upstream... I cannot reproduce the issue with json-schema-to-ts@2.5.4 and vite@3.0.1 https://stackblitz.com/edit/vitejs-vite-qdrpwy?file=BugReproduction.ts With up to date @feathersjs/schema dependencies, I can no longer reproduce the issue at all! |
For some reason copying schema to your src makes the intellisense server not crash... |
The issue only manifests when loading a module from node_modules, if the module is anywhere else in the project, DEFAULT_AJV will be discarded, cleaning up any polluting modules. See PR. |
Other situations I can think of where this is a problem:
Normally we'd use the Feathers App's context... But that would probably break intellisence as the types couldn't be computed at ES Module compile time. Types are already slow to compile because App.ts has no constructor, so typescript can't process types without attempting to execute everything; Rather than processing only top level stateless statements that you'd expect when calling |
This should be fixed in the next prerelease via #2702. Thank you for the PR! |
Steps to reproduce
Expected behavior
Don't crash.
Actual behavior
"schema with key or id "UserPatch" already exists"
System configuration
Module versions: dove pre
Module Loader: esbuild
Reproduction:
use schema instead of safeSchema, wait for server restart, than modify a comment string. When the server is being restarted the bug will crash esbuild wasm as we are building in the same context and something global is conflicting... this might be unavoidable, so I propose wrapping schema with my fix when appropriate.
https://stackblitz.com/edit/bug-feathersjs-schema-2680?file=src%2Fschema%2Fusers.schema.ts,src%2Futils.ts
The text was updated successfully, but these errors were encountered: