Skip to content

Add timeout to wait-until-called#9996

Merged
Gudahtt merged 1 commit intodevelopfrom
add-wait-until-called-timeout
Dec 4, 2020
Merged

Add timeout to wait-until-called#9996
Gudahtt merged 1 commit intodevelopfrom
add-wait-until-called-timeout

Conversation

@Gudahtt
Copy link
Copy Markdown
Member

@Gudahtt Gudahtt commented Dec 3, 2020

The waitUntilCalled utility now has a timeout. It will now throw an error if the stub is not called enough times, rather than blocking forever.

The return type had to be changed to a function, so that we could throw when the timeout is triggered. I tried returning an error that rejected first, but if you don't handle the error synchronously Node.js will consider it to be an unhandled Promise rejected (even if it is handled later on).

I worked around this by resolving in the timeout case as well, so that there is never a "deferred" Promise exception in the timeout case. The returned function re-throws the error if it's given. That way there is never any unhandled Promise rejection.

@Gudahtt Gudahtt requested a review from a team as a code owner December 3, 2020 23:16
@Gudahtt Gudahtt requested a review from darkwing December 3, 2020 23:16
@metamaskbot
Copy link
Copy Markdown
Collaborator

Builds ready [44f7a7d]
Page Load Metrics (396 ± 50 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint307154147
domContentLoaded26459039310349
load26660839610450
domInteractive26458939310349

The `waitUntilCalled` utility now has a timeout. It will now throw an
error if the stub is not called enough times, rather than blocking
forever.

The return type had to be changed to a function, so that we could throw
when the timeout is triggered. I tried returning an error that rejected
first, but if you don't handle the error synchronously Node.js will
consider it to be an unhandled Promise rejected (even if it _is_
handled later on).

I worked around this by resolving in the timeout case as well, so that
there is never a "deferred" Promise exception in the timeout case. The
returned function re-throws the error if it's given. That way there is
never any unhandled Promise rejection.
@Gudahtt Gudahtt force-pushed the add-wait-until-called-timeout branch from 44f7a7d to 2f0862b Compare December 4, 2020 14:36
@metamaskbot
Copy link
Copy Markdown
Collaborator

Builds ready [2f0862b]
Page Load Metrics (438 ± 48 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint319156199
domContentLoaded28460743710048
load28660943810048
domInteractive28460743610048

@darkwing darkwing self-requested a review December 4, 2020 14:58
@Gudahtt Gudahtt merged commit b703319 into develop Dec 4, 2020
@Gudahtt Gudahtt deleted the add-wait-until-called-timeout branch December 4, 2020 17:17
@github-actions github-actions bot locked and limited conversation to collaborators Dec 4, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants