insomnia: [Bug] Maximum call stack size exceeded
- Insomnia Version: insomnia-importers 2.0.14
- Node Version: 11.6.0
Details
When running the code below with a file specification.yml
which is a swagger 2.0 documentation I retrieve the error below. The original file size was ~110kb but I also reduced the size to around ~15kb but it still didn’t work. Someone else encountered this problem also but he didn’t create an issue, the comment can be found here.
const fs = require("fs");
const importers = require("insomnia-importers");
fs.readFile("specification.yml", async (err, data) => {
if (err) throw err;
try {
const output = await importers.convert(data.toString());
console.log(JSON.stringify(output.data, null, 2));
} catch (error) {
console.log("error", error);
}
});
error RangeError: Maximum call stack size exceeded
at Array.forEach (<anonymous>)
at object (/PATH/node_modules/insomnia-importers/src/importers/swagger2.js:300:31)
at generateParameterExample (/PATH/node_modules/insomnia-importers/src/importers/swagger2.js:332:12)
at Object.keys.forEach.propertyName (/PATH/node_modules/insomnia-importers/src/importers/swagger2.js:301:33)
at Array.forEach (<anonymous>)
at object (/PATH/node_modules/insomnia-importers/src/importers/swagger2.js:300:31)
at generateParameterExample (/PATH/node_modules/insomnia-importers/src/importers/swagger2.js:332:12)
at Object.keys.forEach.propertyName (/PATH/node_modules/insomnia-importers/src/importers/swagger2.js:301:33)
at Array.forEach (<anonymous>)
at object (/PATH/node_modules/insomnia-importers/src/importers/swagger2.js:300:31)
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 2
- Comments: 49 (12 by maintainers)
Just stumbled upon this myself, e.g. https://github.com/MicrosoftDocs/vsts-rest-api-specs/blob/master/specification/build/5.0/build.json will fail with “Maximum call stack size exceeded”.
Any big config file will do.
P.S. Same problem with swagger json. P.S.P.S. I have 29k line json for eg.
This bug is back after release 2022.06 till the current beta.
great to hear you fixed it
Hi @xZyph
The fix itself is meant to be implemented inside Insomnia but … you can try to manually modify your specs excluding (deleting) all
$ref
fields inside the file. I used this simple regex"\$ref.*
and it worked but I cannot guarantee the result, you will lose the schema references inside your swagger but it’s a workaround (so, make a backup). You won’t lose them when the fix will be implemented inside Insomnia.Here is an example of what to do:
Before
After
It worked for me, I hope it will works for you too.
Hi folks, I think I may have fixed it (or at least one of the root causes of this bug). I can raise a PR if this sounds reasonable, opinions are welcome, anyway I think it’s a step forward.
File used to test:
Before:
After:

Root cause: Circular references were killing the stack, I simply turned them off and it started working again.
How did you fix it?
Please, check the SwaggerParser documentation about this specific option: Click here.
Thoughts:
really huge (i mean, really really huge)
file imports may still experience this stack size error but those with a performant system should overcome it.vsts-rest-api-specs.json
, it was fine for me too.)Note:
great! thanks! if anything along these lines comes up again please don’t hesitate to reach out 😃
Weird, maybe it was fixed then, I’ll try again this weekend with my old file.
The problem occurs while generating examples for an object, calls again the function and the loop never closes
I am also facing the same issue. My finding is - when you have a relation between 2 classes and they have each other as a property then Swagger UI stuck in a loop.