Skip to content
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

[Bug Report] Error while running the program: RangeError: Maximum call stack size exceeded #246

Closed
JuncalLP opened this issue Mar 13, 2024 · 5 comments · Fixed by #272
Closed
Labels
bug Something isn't working

Comments

@JuncalLP
Copy link

  • OData Version: V4

Running generation with Modes.all and default config throws

Error while running the program: RangeError: Maximum call stack size exceeded
    at propertiesRelatedTo (...@ts-morph\common\dist\typescript.js:63311:35)
    at structuredTypeRelatedToWorker (...@ts-morph\common\dist\typescript.js:62971:23)
    at unionOrIntersectionRelatedTo (...@ts-morph\common\dist\typescript.js:62040:176)

The XML is not large (250KB) but I suspect there are naming issues and complexities that might be causing this. Probably it's not fully an odata2ts issue, but I'd like to be able to pinpoint exactly what on the EDM is causing this.

Saw #243 and updated to 0.32.0 hoping that automatic name clash resolution solved this, but still getting same output. Modes.qobjects works as intended.

@texttechne
Copy link
Contributor

Hi @JuncalLP,

thanks for bringing that up. I need the metadata to reproduce this.

Can you share the metadata file here? Otherwise invite me to a private repo if that's sensible information...

@texttechne texttechne added the bug Something isn't working label Mar 18, 2024
@d-a-s
Copy link

d-a-s commented Apr 17, 2024

I'm getting this same type of error. Metadata available via the public url in the config:

import { ConfigFileOptions, EmitModes, Modes } from '@odata2ts/odata2ts';

const config: ConfigFileOptions = {
  refreshFile: true,
  mode: Modes.service,
  emitMode: EmitModes.js,
  debug: true,
  services: {
    cp: {
      sourceUrl: 'https://stagingapi.casepacer.com/rest',
      source: 'temp/odata.xml',
      output: 'src/api/odataModel',
    },
  },
};

export default config;
full call stack
Emitting JS files (without declaration files)
Error while running the program RangeError: Maximum call stack size exceeded
    at isTypeReferenceWithGenericArguments (/home/user/www/node/cp/react-cp/node_modules/.pnpm/@ts-morph+common@0.19.0/node_modules/@ts-morph/common/dist/typescript.js:63953:49)
    at getRelationKey (/home/user/www/node/cp/react-cp/node_modules/.pnpm/@ts-morph+common@0.19.0/node_modules/@ts-morph/common/dist/typescript.js:63992:14)
    at recursiveTypeRelatedTo (/home/user/www/node/cp/react-cp/node_modules/.pnpm/@ts-morph+common@0.19.0/node_modules/@ts-morph/common/dist/typescript.js:62324:20)
    at isRelatedTo (/home/user/www/node/cp/react-cp/node_modules/.pnpm/@ts-morph+common@0.19.0/node_modules/@ts-morph/common/dist/typescript.js:61862:124)
    at isRelatedToWorker2 (/home/user/www/node/cp/react-cp/node_modules/.pnpm/@ts-morph+common@0.19.0/node_modules/@ts-morph/common/dist/typescript.js:63623:18)
    at compareSignaturesRelated (/home/user/www/node/cp/react-cp/node_modules/.pnpm/@ts-morph+common@0.19.0/node_modules/@ts-morph/common/dist/typescript.js:61254:16)
    at signatureRelatedTo (/home/user/www/node/cp/react-cp/node_modules/.pnpm/@ts-morph+common@0.19.0/node_modules/@ts-morph/common/dist/typescript.js:63612:16)
    at signaturesRelatedTo (/home/user/www/node/cp/react-cp/node_modules/.pnpm/@ts-morph+common@0.19.0/node_modules/@ts-morph/common/dist/typescript.js:63514:29)
    at structuredTypeRelatedToWorker (/home/user/www/node/cp/react-cp/node_modules/.pnpm/@ts-morph+common@0.19.0/node_modules/@ts-morph/common/dist/typescript.js:62982:26)
    at structuredTypeRelatedTo (/home/user/www/node/cp/react-cp/node_modules/.pnpm/@ts-morph+common@0.19.0/node_modules/@ts-morph/common/dist/typescript.js:62439:23)
    at recursiveTypeRelatedTo (/home/user/www/node/cp/react-cp/node_modules/.pnpm/@ts-morph+common@0.19.0/node_modules/@ts-morph/common/dist/typescript.js:62409:21)
    at isRelatedTo (/home/user/www/node/cp/react-cp/node_modules/.pnpm/@ts-morph+common@0.19.0/node_modules/@ts-morph/common/dist/typescript.js:61862:124)
    at isPropertySymbolTypeRelated (/home/user/www/node/cp/react-cp/node_modules/.pnpm/@ts-morph+common@0.19.0/node_modules/@ts-morph/common/dist/typescript.js:63178:16)
    at propertyRelatedTo (/home/user/www/node/cp/react-cp/node_modules/.pnpm/@ts-morph+common@0.19.0/node_modules/@ts-morph/common/dist/typescript.js:63233:25)
    at propertiesRelatedTo (/home/user/www/node/cp/react-cp/node_modules/.pnpm/@ts-morph+common@0.19.0/node_modules/@ts-morph/common/dist/typescript.js:63450:31)
    at structuredTypeRelatedToWorker (/home/user/www/node/cp/react-cp/node_modules/.pnpm/@ts-morph+common@0.19.0/node_modules/@ts-morph/common/dist/typescript.js:62971:23)
    at structuredTypeRelatedTo (/home/user/www/node/cp/react-cp/node_modules/.pnpm/@ts-morph+common@0.19.0/node_modules/@ts-morph/common/dist/typescript.js:62439:23)
    at recursiveTypeRelatedTo (/home/user/www/node/cp/react-cp/node_modules/.pnpm/@ts-morph+common@0.19.0/node_modules/@ts-morph/common/dist/typescript.js:62409:21)
    at isRelatedTo (/home/user/www/node/cp/react-cp/node_modules/.pnpm/@ts-morph+common@0.19.0/node_modules/@ts-morph/common/dist/typescript.js:61862:124)
    at eachTypeRelatedToType (/home/user/www/node/cp/react-cp/node_modules/.pnpm/@ts-morph+common@0.19.0/node_modules/@ts-morph/common/dist/typescript.js:62198:30)
    at unionOrIntersectionRelatedTo (/home/user/www/node/cp/react-cp/node_modules/.pnpm/@ts-morph+common@0.19.0/node_modules/@ts-morph/common/dist/typescript.js:62040:176)
    at structuredTypeRelatedToWorker (/home/user/www/node/cp/react-cp/node_modules/.pnpm/@ts-morph+common@0.19.0/node_modules/@ts-morph/common/dist/typescript.js:62597:25)
    at structuredTypeRelatedTo (/home/user/www/node/cp/react-cp/node_modules/.pnpm/@ts-morph+common@0.19.0/node_modules/@ts-morph/common/dist/typescript.js:62439:23)
    at recursiveTypeRelatedTo (/home/user/www/node/cp/react-cp/node_modules/.pnpm/@ts-morph+common@0.19.0/node_modules/@ts-morph/common/dist/typescript.js:62409:21)
    at isRelatedTo (/home/user/www/node/cp/react-cp/node_modules/.pnpm/@ts-morph+common@0.19.0/node_modules/@ts-morph/common/dist/typescript.js:61862:124)
    at isPropertySymbolTypeRelated (/home/user/www/node/cp/react-cp/node_modules/.pnpm/@ts-morph+common@0.19.0/node_modules/@ts-morph/common/dist/typescript.js:63178:16)
    at propertyRelatedTo (/home/user/www/node/cp/react-cp/node_modules/.pnpm/@ts-morph+common@0.19.0/node_modules/@ts-morph/common/dist/typescript.js:63233:25)
    at propertiesRelatedTo (/home/user/www/node/cp/react-cp/node_modules/.pnpm/@ts-morph+common@0.19.0/node_modules/@ts-morph/common/dist/typescript.js:63450:31)
    at structuredTypeRelatedToWorker (/home/user/www/node/cp/react-cp/node_modules/.pnpm/@ts-morph+common@0.19.0/node_modules/@ts-morph/common/dist/typescript.js:62971:23)
    at structuredTypeRelatedTo (/home/user/www/node/cp/react-cp/node_modules/.pnpm/@ts-morph+common@0.19.0/node_modules/@ts-morph/common/dist/typescript.js:62439:23)
    at recursiveTypeRelatedTo (/home/user/www/node/cp/react-cp/node_modules/.pnpm/@ts-morph+common@0.19.0/node_modules/@ts-morph/common/dist/typescript.js:62409:21)
    at isRelatedTo (/home/user/www/node/cp/react-cp/node_modules/.pnpm/@ts-morph+common@0.19.0/node_modules/@ts-morph/common/dist/typescript.js:61862:124)
    at eachTypeRelatedToType (/home/user/www/node/cp/react-cp/node_modules/.pnpm/@ts-morph+common@0.19.0/node_modules/@ts-morph/common/dist/typescript.js:62198:30)
    at unionOrIntersectionRelatedTo (/home/user/www/node/cp/react-cp/node_modules/.pnpm/@ts-morph+common@0.19.0/node_modules/@ts-morph/common/dist/typescript.js:62040:176)
    at structuredTypeRelatedToWorker (/home/user/www/node/cp/react-cp/node_modules/.pnpm/@ts-morph+common@0.19.0/node_modules/@ts-morph/common/dist/typescript.js:62597:25)
    at structuredTypeRelatedTo (/home/user/www/node/cp/react-cp/node_modules/.pnpm/@ts-morph+common@0.19.0/node_modules/@ts-morph/common/dist/typescript.js:62439:23)
    at recursiveTypeRelatedTo (/home/user/www/node/cp/react-cp/node_modules/.pnpm/@ts-morph+common@0.19.0/node_modules/@ts-morph/common/dist/typescript.js:62409:21)
    at isRelatedTo (/home/user/www/node/cp/react-cp/node_modules/.pnpm/@ts-morph+common@0.19.0/node_modules/@ts-morph/common/dist/typescript.js:61862:124)
    at isPropertySymbolTypeRelated (/home/user/www/node/cp/react-cp/node_modules/.pnpm/@ts-morph+common@0.19.0/node_modules/@ts-morph/common/dist/typescript.js:63178:16)
    at propertyRelatedTo (/home/user/www/node/cp/react-cp/node_modules/.pnpm/@ts-morph+common@0.19.0/node_modules/@ts-morph/common/dist/typescript.js:63233:25)
    at propertiesRelatedTo (/home/user/www/node/cp/react-cp/node_modules/.pnpm/@ts-morph+common@0.19.0/node_modules/@ts-morph/common/dist/typescript.js:63450:31)
    at structuredTypeRelatedToWorker (/home/user/www/node/cp/react-cp/node_modules/.pnpm/@ts-morph+common@0.19.0/node_modules/@ts-morph/common/dist/typescript.js:62971:23)
    at structuredTypeRelatedTo (/home/user/www/node/cp/react-cp/node_modules/.pnpm/@ts-morph+common@0.19.0/node_modules/@ts-morph/common/dist/typescript.js:62439:23)
    at recursiveTypeRelatedTo (/home/user/www/node/cp/react-cp/node_modules/.pnpm/@ts-morph+common@0.19.0/node_modules/@ts-morph/common/dist/typescript.js:62409:21)
    at isRelatedTo (/home/user/www/node/cp/react-cp/node_modules/.pnpm/@ts-morph+common@0.19.0/node_modules/@ts-morph/common/dist/typescript.js:61862:124)
    at eachTypeRelatedToType (/home/user/www/node/cp/react-cp/node_modules/.pnpm/@ts-morph+common@0.19.0/node_modules/@ts-morph/common/dist/typescript.js:62198:30)
    at unionOrIntersectionRelatedTo (/home/user/www/node/cp/react-cp/node_modules/.pnpm/@ts-morph+common@0.19.0/node_modules/@ts-morph/common/dist/typescript.js:62040:176)
    at structuredTypeRelatedToWorker (/home/user/www/node/cp/react-cp/node_modules/.pnpm/@ts-morph+common@0.19.0/node_modules/@ts-morph/common/dist/typescript.js:62597:25)
    at structuredTypeRelatedTo (/home/user/www/node/cp/react-cp/node_modules/.pnpm/@ts-morph+common@0.19.0/node_modules/@ts-morph/common/dist/typescript.js:62439:23)
    at recursiveTypeRelatedTo (/home/user/www/node/cp/react-cp/node_modules/.pnpm/@ts-morph+common@0.19.0/node_modules/@ts-morph/common/dist/typescript.js:62409:21)

@texttechne
Copy link
Contributor

Hi,

thanks @d-a-s for the next example. @JuncalLP already provided me with one, but it's always good to have more 😄

Current Status Quo

Actually repeating what I've said in #251.

The generation actually works fine when emitting TS, but as soon as this get's typechecked (tsc) or included in source code, the error occurs. The same happens when generating js_dts or js files, only in one go. So in these cases the generation fails directly with this error.

It seems that the types are too complex (see also microsoft/TypeScript#33460). I cannot find a bug in the code. Experiments with generating less to overcome the error have shown that it's more or less random what to leave out: As soon as the complexity is reduced it might work. Well, it leads me to the conclusion that the typing is just too complex... of course, I might be wrong here...

My next solution approach: Generate an API model for the services. I suspect that TS has problems to use the generated services as types without already fully checking the service...

@texttechne
Copy link
Contributor

I opened an issue with TypeScript: see microsoft/TypeScript#58439

@texttechne texttechne linked a pull request May 16, 2024 that will close this issue
@texttechne
Copy link
Contributor

Hi @JuncalLP and @d-a-s,
both of your services should work now according to my tests.
Release:

  • @odata2ts/odata-service version 0.19.0
  • @odata2ts/odata2ts version 0.35.0

Thanks to both of you for the invaluable examples!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants