openwallet-foundation / credo-ts

Typescript framework for building decentralized identity and verifiable credential solutions
https://credo.js.org
Apache License 2.0
260 stars 197 forks source link

Incompatibility with class-transformer >0.3.1 #174

Closed genaris closed 3 years ago

genaris commented 3 years ago

I could succesfully get the framework up and running by following the exact instructions from README. However, I was having a hard time when trying to use the packed framework from another project: there were some situations where I got some 'Maximum call stack size exceeded' error coming from class-transformer when converting a Connection to JSON:

RangeError: Maximum call stack size exceeded
    at TransformOperationExecutor.transform (/home/genaris/agent-test/node_modules/class-transformer/cjs/TransformOperationExecutor.js:29:14)
    at /home/genaris/agent-test/node_modules/class-transformer/cjs/TransformOperationExecutor.js:62:40
    at Array.forEach (<anonymous>)
    at TransformOperationExecutor.transform (/home/genaris/agent-test/node_modules/class-transformer/cjs/TransformOperationExecutor.js:34:19)
    at TransformOperationExecutor.transform (/home/genaris/agent-test/node_modules/class-transformer/cjs/TransformOperationExecutor.js:259:43)
    at /home/genaris/agent-test/node_modules/class-transformer/cjs/TransformOperationExecutor.js:62:40
    at Array.forEach (<anonymous>)
    at TransformOperationExecutor.transform (/home/genaris/agent-test/node_modules/class-transformer/cjs/TransformOperationExecutor.js:34:19)
    at TransformOperationExecutor.transform (/home/genaris/agent-test/node_modules/class-transformer/cjs/TransformOperationExecutor.js:259:43)
    at TransformOperationExecutor.transform (/home/genaris/agent-test/node_modules/class-transformer/cjs/TransformOperationExecutor.js:259:43)

Then I noticed that the class-transformer module in my agent-test project was actually a newer version than the one downloaded in the aries-framework-javascript I've packed (0.3.2 vs 0.3.1). This was due to the yarn.lock file uploaded in the repo, as framework's package.json file states "class-transformer": "^0.3.1".

Actually, if I remove yarn.lock from a clean repo and execute yarn install && yarn pack, I get several errors from classes related to this module (see pack-error.log).

If I simply fix class-transformer to 0.3.1 in framework's package.json file, everything works flawlessly, so this makes me think that there is something wrong with this new class-transformer 0.3.2 (released less than a month ago) or one of its dependencies.

TimoGlastra commented 3 years ago

Do you have an example that showcases the error so I can easily reproduce? class-transformer recently released breaking changes in a patch version so there's some breaking changes. There is already a PR open that updates to 0.3.2 (#108 ) so it's not really viable to fix the version to 0.3.1

@jakubkoci is this the same error you got?

jakubkoci commented 3 years ago

@TimoGlastra Yes, this is exactly the same error I had. It could be good if we can merge #108? I think there are just 4 small notes unresolved.

Maybe the problem is not the version 0.3.2 but that you have different versions in the framework and in your project. However, I'm also using 0.3.1 now. I'll try it with 0.3.2 and let you know.

jakubkoci commented 3 years ago

Aha, maybe I would need the updates from #108 to test it correctly with 0.3.2 right? I think if we set the version to 0.3.2 without ^ or ~ it should work 🤔

genaris commented 3 years ago

Thank you for your prompt actions! After the merge, the problem is gone from my side, so I think it's appropriate to close this issue.