Stack overflow when type checking very large objects
See original GitHub issueI have been using sanctuary-def
for utility modules in a meteor app recently which has been mostly a joy. It is frequently necessary in meteor to read from a singleton app instance
// you may have seen...
import { Meteor } from 'meteor/meteor'
I was requiring this object as an argument to some checked functions, at first representing it in the signature as a $.RecordType
that had some default properties, but sanctuary
threw stack overflow errors when it came time to actually check this object to the tune of
W20161007-12:22:14.473(-4)? (STDERR) RangeError: Maximum call stack size exceeded
W20161007-12:22:14.473(-4)? (STDERR) at validate (/project-path/node_modules/sanctuary-def/index.js:332:18)
W20161007-12:22:14.475(-4)? (STDERR) at Object._test (/project-path/node_modules/sanctuary-def/index.js:276:14)
W20161007-12:22:14.475(-4)? (STDERR) at /project-path/node_modules/sanctuary-def/index.js:856:53
W20161007-12:22:14.475(-4)? (STDERR) at chain (/project-path/node_modules/sanctuary-def/index.js:82:26)
W20161007-12:22:14.476(-4)? (STDERR) at /project-path/node_modules/sanctuary-def/index.js:854:14
W20161007-12:22:14.476(-4)? (STDERR) at map (/project-path/node_modules/sanctuary-def/index.js:120:62)
W20161007-12:22:14.478(-4)? (STDERR) at recur (/project-path/node_modules/sanctuary-def/index.js:843:19)
W20161007-12:22:14.478(-4)? (STDERR) at determineActualTypesStrict (/project-path/node_modules/sanctuary-def/index.js:892:31)
W20161007-12:22:14.478(-4)? (STDERR) at recur (/project-path/node_modules/sanctuary-def/index.js:1044:32)
W20161007-12:22:14.479(-4)? (STDERR) at $.test (/project-path/node_modules/sanctuary-def/index.js:1079:12)
W20161007-12:22:14.479(-4)? (STDERR) at /project-path/node_modules/sanctuary-def/index.js:1086:16
=> Exited with code: 1
So i changed the signature to expect $.Object
, which yielded the same result.
One option is to just avoid this mess by having the calling code pick whatever it needs off of the large object before calling my utilities, but that kind of makes me sad.
Issue Analytics
- State:
- Created 7 years ago
- Comments:9 (3 by maintainers)
Top Results From Across the Web
How can I avoid type checking a python object if its attributes ...
with a message telling them the number they gave me is too big. I would like to keep this message specific. But if...
Read more >What is Rust and why is it so popular? - Stack Overflow Blog
Statically-typed languages allow for compiler-checked constraints on the data and its behavior, alleviating cognitive overhead and ...
Read more >The Most Asked TypeScript Questions on StackOverflow
A class can only implement an object type or intersection of object types with statically known members. See the TypeScript playground. Summary ...
Read more >Stack Canaries with GCC: Checking for Stack Overflow at ...
Stack overflows are probably the number 1 enemy of embedded applications: a call to a a printf() monster likely will use too much...
Read more >Heap overflow and Stack overflow - GeeksforGeeks
If we declare large number of local variables or declare an array or matrix or any higher dimensional array of large size can...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks for the bug report, @Koleok. Could you see whether you can reproduce this against
master
? @Avaq and I spent some time debugging a similar issue a few weeks ago only to realize that it’s no longer a problem onmaster
.That would sadden me too. We can certainly do better. 😃
I’m pleased to hear you’re finding sanctuary-def useful (and fun to use).
Update: For now i had to just fork
sanctuary-def
and do annpm version minor
to get it away from the0.6.x
specified in thesanctuary
deps. I’ll look for those new versions!