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

Update promise.wait to throw an error when timeout reached or interrupted #723

Merged

Conversation

chipsenkbeil
Copy link
Contributor

Per the comment I made in our main org roam issue, I discovered that Promise.wait does not throw an error when the timeout is reached. Instead, it returns nil.

This can be a problem if you're returning OrgPromise<nil>, as it misleads the promise as succeeding when in reality it may have not completed yet.

This updates Promise.wait to check the return values from vim.wait to determine if a value should be returned or if an error should be thrown.

chipsenkbeil added a commit to chipsenkbeil/org-roam.nvim that referenced this pull request May 6, 2024
chipsenkbeil added a commit to chipsenkbeil/org-roam.nvim that referenced this pull request May 6, 2024
Copy link
Member

@kristijanhusak kristijanhusak left a comment

Choose a reason for hiding this comment

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

Looks good, just some minor refactoring around the checks.

lua/orgmode/utils/promise.lua Outdated Show resolved Hide resolved
Co-authored-by: Kristijan Husak <husakkristijan@gmail.com>
@chipsenkbeil
Copy link
Contributor Author

Looks good, just some minor refactoring around the checks.

Good to go :)

@kristijanhusak kristijanhusak merged commit 03a2078 into nvim-orgmode:master May 6, 2024
6 checks passed
@kristijanhusak
Copy link
Member

Thanks!

SlayerOfTheBad pushed a commit to SlayerOfTheBad/orgmode that referenced this pull request Aug 16, 2024
…pted (nvim-orgmode#723)

* Update promise.wait to throw an error when timeout reached or interrupted

* Revert some formatting changes

* Fix lint error

* Add test to demonstrate functionality

* Update lua/orgmode/utils/promise.lua

Co-authored-by: Kristijan Husak <husakkristijan@gmail.com>

---------

Co-authored-by: Kristijan Husak <husakkristijan@gmail.com>
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.

2 participants