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

Avoid unref-ing timer while awaiting status upload #1539

Merged
merged 1 commit into from
Feb 13, 2023

Conversation

aeisenberg
Copy link
Contributor

@aeisenberg aeisenberg commented Feb 13, 2023

We had a problem where waitForProcessing was not completing before the node process ends. This is because using unref would allow the node process to end without having the delay function complete.

Merge / deployment checklist

  • Confirm this change is backwards compatible with existing workflows.
  • Confirm the readme has been updated if necessary.
  • Confirm the changelog has been updated if necessary.

@aeisenberg aeisenberg requested a review from a team as a code owner February 13, 2023 21:26
@aeisenberg
Copy link
Contributor Author

This was not a user-facing bug, so no change note required.

henrymercer
henrymercer previously approved these changes Feb 13, 2023
src/util.ts Outdated
* @param milliseconds time to delay
* @param opts.unref if true, the timer will not prevent the process from exiting
*/
export async function delay(milliseconds: number, opts: { unref: boolean }) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Idea you can take or leave: it might make our code slightly more readable to rename unref to something like allowProcessExitDuringDelay.

henrymercer
henrymercer previously approved these changes Feb 13, 2023
src/util.ts Outdated
return new Promise((resolve) => setTimeout(resolve, milliseconds).unref());
/**
* @param milliseconds time to delay
* @param unref if true, the timer will not prevent the process from exiting
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: update JSDoc. The spec recommends writing down two @params for a destructured parameter, which seems a little verbose (https://jsdoc.app/tags-param.html#parameters-with-properties).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm...that's a little verbose, but I'll go with the spec.

We had a problem where `waitForProcessing` was not completing before
the node process ends. This is because using `unref` would allow the
node process to end without having the `delay` function complete.
@aeisenberg aeisenberg merged commit e00cd12 into main Feb 13, 2023
@aeisenberg aeisenberg deleted the aeisenberg/unref-delay branch February 13, 2023 23:24
@github-actions github-actions bot mentioned this pull request Feb 24, 2023
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants