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

Change rethrowAsync()'s behavior in test mode #20252

Closed
lannka opened this issue Jan 10, 2019 · 8 comments
Closed

Change rethrowAsync()'s behavior in test mode #20252

lannka opened this issue Jan 10, 2019 · 8 comments

Comments

@lannka
Copy link
Contributor

lannka commented Jan 10, 2019

To follow the conversation here

From a testing point of view, removing rethrowAsync will greatly reduce the amount of flakiness we see. However, is there a valid use case for doing it in the runtime? Why was it added in the first place? Does it prevent the runtime from blocking when it encounters an error, perhaps?

Can we change rethrowAsync to console.error() + reportErrorToServer()

/cc @erwinmombay @jridgewell @dvoytenko @choumx @rsimha

@jridgewell
Copy link
Contributor

Copying @dvoytenko's #20233 (comment):

@rsimha Not sure if this is the best forum for rethrowAsync discussion, but to kick it off. The original intent with rethrowAsync was this: "Don't block the code, but still treat it as an error downstream, including reporting to console, analytics services, diagnostics logging". I realize that it caused us some paint with tests, but I think we could try to address that pain in a couple of different ways and maybe that'd be an improvement over the current state. E.g. something like:

function rethrowAsync(error) {
  if (TESTING) {
    // E.g. these errors could be then used for test assertions.
    TESTING.collectErrors(error);
  } else {
    // Normal PROD behavior.
    setInterval(() => {throw error;});
  }
}

With something like this, the if (TESTING) part would be stripped from PROD binary.

Overall, IMHO, I prefer rethrowAsync to user().log() and dev().log(). I'd prefer we relied on logging packages as little as possible. rethrowAsync is essentially a proxy to throw new Error() and reads much cleaner. But that's a bigger conversation.

@jridgewell
Copy link
Contributor

I'm also supportive of rethrowAsync, for exactly the reasons @dvoytenko's has above.

@lannka
Copy link
Contributor Author

lannka commented Jan 10, 2019

Right, I do see the value of throwing an error (stack trace etc).

Can you explain what logging packages is?

@jridgewell
Copy link
Contributor

src/log.js

@lannka
Copy link
Contributor Author

lannka commented Jan 15, 2019

SG, let's go with @dvoytenko's proposal.

@torch2424 since you will be working on the amp-experiment soon, it will be very important to unmute the tests. Assigning to you.

@ampprojectbot
Copy link
Member

This issue doesn't have a category which makes it harder for us to keep track of it. @torch2424 Please add an appropriate category.

@dreamofabear dreamofabear changed the title Do we need rethrowAsync? Change rethrowAsync()'s behavior in test mode Jan 24, 2019
@torch2424 torch2424 added this to To Do in Ads & Analytics Fixit - April 2019 via automation May 2, 2019
@rsimha rsimha added this to FixIt week in Infrastructure Jul 16, 2019
@rsimha
Copy link
Contributor

rsimha commented May 1, 2020

This is another worthwhile effort that fits under the umbrella of #14360.

@rsimha rsimha removed this from FixIt week in Infrastructure Feb 22, 2021
@rsimha rsimha added this to To do in `wg-infra` Fixit Week 2/2021 via automation Feb 22, 2021
@rileyajones
Copy link
Contributor

I can't seem to reproduce this issue anymore. If anyone thinks this is still happening, please reopen this ticket.
@dvoytenko @lannka

`wg-infra` Fixit Week 2/2021 automation moved this from To do to Done Feb 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

8 participants