-
Notifications
You must be signed in to change notification settings - Fork 122
-
Notifications
You must be signed in to change notification settings - Fork 122
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
[type] infinite stack when resolving recursive type parameters #477
Comments
That's fixed |
Hello @marcj , it seems that I'm getting a similar issue in the latest
import { test } from '@jest/globals';
import {cast} from "../src/serializer-facade";
type JSONValue = null | boolean | number | string | JSONObject | JSONArray;
type JSONArray = JSONValue[];
export type JSONObject = {
[k: string]: JSONValue;
};
test('complex recursive union type does not cause stack size exceeding', () => {
const user = cast<JSONObject>({ username: 'Peter' });
}); Then execute Here's what I get:
|
Previously each serializer template was required to handle circular structures when needed. Now, the serializer framework itself handles it. Also, BSON property name writer refactored so that auto-handling of circular references works correctly. For JIT code generation env DEBUG=deepkit now pretty formats it for easier debugging. ref #477
@alpharder good catch, thanks. indeed, some circular references weren't detected correctly. I've refactored the code to move the circular reference solver into the typeguard/serializer API itself so the various type templates don't have to take care of that. This should now support much more circular references, if not all. I've added your JSONValue type to our test suite to make sure it keeps working. fixed in 5f6bd12 |
@marcj wow, that change is massive, thank you for the quick fix! Looking forward for the next release. |
@alpharder released in 1.0.1-alpha.124 |
Running
resolveReceiveType
eventually causes a V8 OOMThe text was updated successfully, but these errors were encountered: