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

🐢Tests using wrapped rethrowAsync take a very long time. #25725

Closed
calebcordry opened this issue Nov 21, 2019 · 6 comments
Closed

🐢Tests using wrapped rethrowAsync take a very long time. #25725

calebcordry opened this issue Nov 21, 2019 · 6 comments

Comments

@calebcordry
Copy link
Member

I don't think this is a problem on travis because we increase the timeout limit, but when running tests locally this causes consistent failure on macbook pro.

We have a function that stubs usage of rethrowAsync in tests

function preventAsyncErrorThrows() {

This stub eventually calls

self.__AMP_REPORT_ERROR(error);

In these stubed tests self.__AMP_REPORT_ERROR() is a ref to

export function reportError(error, opt_associatedElement) {

In that function we call

output.call(console, error.stack);

That line of code takes between 2.7 - 3.1 seconds to execute on my laptop!!?!!?

console error here is also stubbed to be a no op

consoleErrorStub.callsFake(() => {});

I put some console.times in here to see what was going on, and from the call to the time the NOOP function is executed accounts for the slowness. Unfortunately all the code that is executed in between is part of our external testing packages so I am not sure there is a good fix. Maybe reevalute how we are stubbing things?

If you want to see my "profiling" I have a draft pr here #25724 if you pull those changes and run gulp unit --files=test/unit/test-3p.js --verbose you should be able to repro and see some times being logged.

@calebcordry
Copy link
Member Author

to/ @ampproject/wg-infra cc/ @ampproject/wg-ads

@calebcordry
Copy link
Member Author

Had another thought, maybe this is slow because we are passing around the whole error stack? Just a guess though.

@rsimha
Copy link
Contributor

rsimha commented Nov 21, 2019

Nice sleuthing, @calebcordry.

For context, rethrowAsync() was stubbed in order to prevent errors from one test from leaking into a subsequent test (#16916), and console.error was stubbed (via the allowConsoleError mechanism) in order to keep tests honest about runtime errors that may occur during execution (#14336).

I agree we should work on improving how tests can legitimately surface errors. Happy to discuss ideas.

/cc @estherkim who is going to work on overall test reliability.

@calebcordry
Copy link
Member Author

Thanks! I actually like the idea of the stubbed errors etc, but I think this stubception™ might be confusing sinon. Maybe we can convince them to work on their perf for things like this :)

@rsimha
Copy link
Contributor

rsimha commented May 1, 2020

Resetting assignees since our projects have changed since this was filed. However, I think this is a good area to investigate, since the potential gains can be very high. Bumping to P2.

@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

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

No branches or pull requests

4 participants