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

Add a wait() method #206

Closed
kanongil opened this issue Sep 17, 2017 · 1 comment
Closed

Add a wait() method #206

kanongil opened this issue Sep 17, 2017 · 1 comment
Assignees
Labels
Milestone

Comments

@kanongil
Copy link
Member

@kanongil kanongil commented Sep 17, 2017

With domain support going away in Hapi, an errant throw inside a setTimeout() will cause the uncaughtException event to be emitted. This can be mitigated by awaiting on a delay() method:

const delay = function (duration) {

    return new Promise((resolve) => setTimeout(resolve, duration));
};

This will change something like:

setTimeout(() => {
    /* my delayed code */
), 100);

to:

await delay(100);
/* my delayed code */
@hueniverse

This comment has been minimized.

Copy link
Member

@hueniverse hueniverse commented Sep 17, 2017

For now, I am writing these utilities locally where needed. As v17 gets more mature, we will collect these utils and put them here. I've been writing await internal.wait(100) quite a bit...

@hueniverse hueniverse changed the title Add a delay() method Add a wait() method Sep 26, 2017
@hueniverse hueniverse self-assigned this Sep 26, 2017
@hueniverse hueniverse added the feature label Sep 26, 2017
@hueniverse hueniverse added this to the 4.2.1 milestone Sep 26, 2017
@hueniverse hueniverse closed this Sep 30, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.