Avoid unref-ing timer while awaiting status upload#1539
Merged
aeisenberg merged 1 commit intomainfrom Feb 13, 2023
Merged
Conversation
Contributor
Author
|
This was not a user-facing bug, so no change note required. |
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 }) { |
Contributor
There was a problem hiding this comment.
Idea you can take or leave: it might make our code slightly more readable to rename unref to something like allowProcessExitDuringDelay.
5eb309d to
969e487
Compare
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 |
Contributor
There was a problem hiding this comment.
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).
Contributor
Author
There was a problem hiding this comment.
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.
969e487 to
a2487fb
Compare
henrymercer
approved these changes
Feb 13, 2023
6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
We had a problem where
waitForProcessingwas not completing before the node process ends. This is because usingunrefwould allow the node process to end without having thedelayfunction complete.Merge / deployment checklist