Forestadmin:update-typings fails with "Maximum call stack size exceeded" on WSL2 and Windows (works on macOS)

Hi everyone,

When I run npm run forestadmin:update-typings, I encounter the following error on Windows and WSL2 (Ubuntu) environments:

/home/artrack/projects/johndoe/forestadmin/node_modules/@forestadmin/datasource-mongoose/dist/mongoose/schema.js:107
        const [prefix, suffix] = path.split(/\.(.*)/);
                                      ^

RangeError: Maximum call stack size exceeded
    at String.split (<anonymous>)
    at MongooseSchema.getSubSchema (...)
    ...

This works fine on macOS using the same codebase, so the issue seems to be platform-specific.

Environment:

  • Node.js: v22.13.1
  • @forestadmin/forest-cloud: latest
  • Running on: macOS (works), Windows/WSL2 (fails)

Thanks in advance!

Hello @artpumpkin and welcome to the community!

Could I ask you to check the package.json in the repository for the @forestadmin/datasource-mongoose dependency, is the version 1.12.1 ? If it is, could you retry with version 1.12.0 after updating your node_modules. Thanks

Hey Dogan,

I tried both versions, same issue.

Best regards,

Hello,
I’m working on a patch to fix the bug. I will send you a message when the patch is released.
Thanks,
Alban

1 Like

Hey Alban,

I appreciate it, best of luck.

Thanks.

Could you pull the latest datasource-mongoose version and try again please?

Hey Alban,

Sorry for the late reply, after updating both @forestadmin/forest-cloud and @forestadmin/datasource-mongoose to their latest version, I got a different trace call:

āœ– An unexpected error occurred.
Please reach out for help in our Developers community (https://community.forestadmin.com/)
/home/artrack/projects/johndoe/forestadmin/node_modules/@forestadmin/datasource-mongoose/dist/mongoose/schema.js:104
        if (!path)
        ^

RangeError: Maximum call stack size exceeded
    at MongooseSchema.getSubSchema (/home/artrack/projects/johndoe/forestadmin/node_modules/@forestadmin/datasource-mongoose/dist/mongoose/schema.js:104:9)
    at /home/artrack/projects/johndoe/forestadmin/node_modules/@forestadmin/datasource-mongoose/dist/mongoose/schema.js:37:33
    at Array.flatMap (<anonymous>)
    at MongooseSchema.listPathsMatching (/home/artrack/projects/johndoe/forestadmin/node_modules/@forestadmin/datasource-mongoose/dist/mongoose/schema.js:36:14)
    at /home/artrack/projects/johndoe/forestadmin/node_modules/@forestadmin/datasource-mongoose/dist/mongoose/schema.js:40:18
    at Array.flatMap (<anonymous>)
    at MongooseSchema.listPathsMatching (/home/artrack/projects/johndoe/forestadmin/node_modules/@forestadmin/datasource-mongoose/dist/mongoose/schema.js:36:14)
    at /home/artrack/projects/johndoe/forestadmin/node_modules/@forestadmin/datasource-mongoose/dist/mongoose/schema.js:40:18
    at Array.flatMap (<anonymous>)
    at MongooseSchema.listPathsMatching (/home/artrack/projects/johndoe/forestadmin/node_modules/@forestadmin/datasource-mongoose/dist/mongoose/schema.js:36:14)

Node.js v22.13.1

Hello, thanks for the feedback.
Does it still work on macos?

Hello @artpumpkin,
We have managed to reproduce the issue locally, and we are currently working on a fix.
Thanks for your patience :pray: