question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Stack overflow when type checking very large objects

See original GitHub issue

I 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:closed
  • Created 7 years ago
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
davidchamberscommented, Oct 7, 2016

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 on master.

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.

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).

1reaction
Koleokcommented, Oct 10, 2016

Update: For now i had to just fork sanctuary-def and do an npm version minor to get it away from the 0.6.x specified in the sanctuary deps. I’ll look for those new versions!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found