Throw error if beforeSave or beforeClose yield #64
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.
This fixes an edge case where one of the callbacks could yield right before or during
game:BindToClose
which means the save won't have started andAutoSave
won't wait for the document to close.This could be fixed without restricting yielding but there is another awkward API issue this fixes: For example, if
beforeSave
yields and:close
is called during the yield, the close will throw an error since:close
can't be called during thebeforeSave
callback. This could also technically be fixed by checking thecoroutine.status
of thebeforeSave
thread before throwing this error. However, if the:close
didn't yield in its callbacks theclose
request would happen before thesave
and that would result in a save happening after the close which is not good.We may find solutions to these edge cases but I feel that it's more correct to not allow yielding.