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

Ensure "pause on uncaught" exceptions pauses in correct location. #1172

Merged
merged 1 commit into from
Oct 13, 2020

Conversation

rwjblue
Copy link
Member

@rwjblue rwjblue commented Oct 13, 2020

Prior to this change (since 90f948) when an error occured after initial append (during the updating VM lifetime) using the dev tools feature for "pause on uncaught exceptions" would never pause execution in userland code, it would always pause at the location that the UpdatingVM was re-throwing the error.

This change restores the proper developer ergonomics of "pause on uncaught exceptions" while still preserving the original intent of the changes that were landed in this area for 90f948 (preventing invocation of resetTracking when "all is well").

@pzuraq
Copy link
Member

pzuraq commented Oct 13, 2020

@rwjblue can we wrap this entire try/finally in DEBUG? The original motivation was to avoid a depot which the try/finally was causing

@rwjblue
Copy link
Member Author

rwjblue commented Oct 13, 2020

The original motivation was to avoid a depot which the try/finally was causing

I think this is incorrect. The try/finally was not causing the deopts, the code in the finally was causing the deopts. That is only going to be ran when an error happens and shouldn't be deopting in prod.

can we wrap this entire try/finally in DEBUG?

I'd prefer not to duplicate the entire block for prod/debug (largely because we don't actually test prod), or do you mean to avoid the finally block contents in debug builds?

@pzuraq
Copy link
Member

pzuraq commented Oct 13, 2020

Another thing I just noticed, this updates the try/catch in the updating VM, we also need to update the try/catch in the append VM (which is where the deopt was originally occurring).

https://github.com/glimmerjs/glimmer-vm/blob/master/packages/@glimmer/runtime/lib/vm/append.ts#L559

I'd prefer not to duplicate the entire block for prod/debug (largely because we don't actually test prod), or do you mean to avoid the finally block contents in debug builds?

It'd probably be enough to create a separate method which does the wrapping:

execute() {
  if (DEBUG) {
    try {
      this._execute();
    } finally {
      // ...
    }
  } else {
    this._execute();
  }
}

This way we just avoid any funkiness with try/finally at all potentially. We could also verify that this new strategy does not deopt, it'll just take a while, and while I agree with your assessment, I don't actually understand why it was deopting in the first place still. None of the conditions should ever have been checked unless an error was thrown, and errors shouldn't occur at all in prod, yet it was still happening.

We didn't see a major perf win from fixing this specific deopt in the end, so if you think it would make more sense to just not wrap in DEBUG and do this strategy I think it's probably fine. We'll have to rework this anyways if we want to ever actually handle errors during render.

@rwjblue rwjblue force-pushed the remove-try-catch-in-updating-vm branch from 3bb7808 to d72a617 Compare October 13, 2020 16:58
@rwjblue
Copy link
Member Author

rwjblue commented Oct 13, 2020

Thanks for the pointers there! Just updated, mind taking another look?

@rwjblue rwjblue requested a review from pzuraq October 13, 2020 16:59
Prior to this change (since 90f948)  when an error occured after initial
append (during the updating VM lifetime) using the dev tools feature for
"pause on uncaught exceptions" would **never** pause execution in
userland code, it would always pause at the location that the
`UpdatingVM` was re-throwing the error.

This change restores the proper developer ergonomics of "pause on
uncaught exceptions" while still preserving the original intent of the
changes that were landed in this area for 90f948 (preventing invocation
of `resetTracking` when "all is well").
@rwjblue rwjblue force-pushed the remove-try-catch-in-updating-vm branch from d72a617 to 3269ca3 Compare October 13, 2020 17:21
@rwjblue rwjblue merged commit c00d700 into master Oct 13, 2020
@rwjblue rwjblue deleted the remove-try-catch-in-updating-vm branch October 13, 2020 18:21
rwjblue added a commit to emberjs/ember.js that referenced this pull request Oct 17, 2020
Fixes two major issues:

* Ensure "pause on uncaught" exceptions pauses in correct location
  (glimmerjs/glimmer-vm#1172)
* Log template heirarchy to the console for any errors thrown during
  rendering (glimmerjs/glimmer-vm#1169)
kategengler pushed a commit to emberjs/ember.js that referenced this pull request Oct 19, 2020
Fixes two major issues:

* Ensure "pause on uncaught" exceptions pauses in correct location
  (glimmerjs/glimmer-vm#1172)
* Log template heirarchy to the console for any errors thrown during
  rendering (glimmerjs/glimmer-vm#1169)

(cherry picked from commit e8cfd08)
locks pushed a commit to emberjs/ember.js that referenced this pull request Oct 27, 2020
Fixes two major issues:

* Ensure "pause on uncaught" exceptions pauses in correct location
  (glimmerjs/glimmer-vm#1172)
* Log template heirarchy to the console for any errors thrown during
  rendering (glimmerjs/glimmer-vm#1169)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants