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

Improve stack traces for port errors #770

Merged
merged 1 commit into from Dec 12, 2016

Conversation

Projects
None yet
4 participants
@rtfeldman
Member

rtfeldman commented Dec 3, 2016

Suppose we have a bad port invocation that's going to blow up, in a file called index.html:

function invokeBustedPort() {
  app.ports.foo.send(null);
}

// alternatively, for a post-init error: setTimeout(invokeBustedPort, 500);
invokeBustedPort();

Before

The stack trace doesn't include the offending function, invokeBustedPort, or a useful line number indicating where the function was invoked:
screen shot 2016-12-03 at 12 24 01 am

After

Now it includes both!
screen shot 2016-12-03 at 12 30 38 am

What Changed

The basic idea is to do the decoder check immediately inside send, and throw new Error inside send so it preserves the best stack trace information.

This means that in the preInit case it fails slightly sooner, because it does the check before init - and then defers the actual value sending - instead of deferring both.

@process-bot

This comment has been minimized.

Show comment
Hide comment
@process-bot

process-bot Dec 3, 2016

Thanks for the pull request! Make sure it satisfies this checklist. My human colleagues will appreciate it!

Here is what to expect next, and if anyone wants to comment, keep these things in mind.

process-bot commented Dec 3, 2016

Thanks for the pull request! Make sure it satisfies this checklist. My human colleagues will appreciate it!

Here is what to expect next, and if anyone wants to comment, keep these things in mind.

@turboMaCk

This comment has been minimized.

Show comment
Hide comment
@turboMaCk

turboMaCk Dec 4, 2016

Contributor

This is great! I was dealing with this week ago. This improvement will make it much easier. 👍

Contributor

turboMaCk commented Dec 4, 2016

This is great! I was dealing with this week ago. This improvement will make it much easier. 👍

@evancz evancz merged commit d302d20 into master Dec 12, 2016

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details
@evancz

This comment has been minimized.

Show comment
Hide comment
@evancz

evancz Dec 12, 2016

Member

Makes sense to me, nice improvement!

Member

evancz commented Dec 12, 2016

Makes sense to me, nice improvement!

@evancz evancz deleted the stack-traces branch Dec 12, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment