Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jsii kernel gives quite unhelpful error message when serializing a function #806

Closed
rix0rrr opened this issue Sep 23, 2019 · 1 comment
Closed
Assignees
Labels
bug This issue is a bug. needs-triage This issue or PR still needs to be triaged.

Comments

@rix0rrr
Copy link
Contributor

rix0rrr commented Sep 23, 2019

🐛 Bug Report

Now obviously, functions should never get passed to the jsii kernel to serialize, so this is already a bug. But if they do:

jsii.errors.JavaScriptError: 
  Error: Resolution error: JSII kernel assumption violated, undefined is not an object.

Upon reading this error message you'll tear out your hair trying to figure out how this is possible, because no code path looks like it should allow undefined at that point.

This is because:

> JSON.stringify(function() { return 666; })
undefined

Thanks JavaScript!

Anyway, explicitly testing for functions using typeof value === 'function' and throwing a more appropriate error message would be VERY VERY helpful.

@rix0rrr rix0rrr added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Sep 23, 2019
@RomainMuller
Copy link
Contributor

The error message was improved & now provides a suggestion as per a probable cause, too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. needs-triage This issue or PR still needs to be triaged.
Projects
None yet
Development

No branches or pull requests

2 participants