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.
Description
There is an issue in the Swift SDK where if a lot of updates are added in a small timeframe it results in a buffer overflow for the table update emitting function. When the buffer overflow happens the emit is suspended for an indeterminant amount of time and because of this the watch query does not receive a re-query event timeously. It therefore does not re-run when one would expect resulting in it appearing that the watch query does not work.
This PR fixes this issue by:
Increasing the buffer overflow amount
Implements
tryEmit
as opposed toemit
so that if the emit fails it instead results in a warning log as opposed to suspending. The reason this is preferred is that it gives a clear indication of the issue (if it ever comes up again) as opposed to leaving it to maybe suspended resulting in a hard-to-diagnose issue. We could also opt instead of usingSUSPEND
for the buffer overflow behaviour to rather useDROP_OLDEST
orDROP_LATEST
, however these are not ideal as we may lose a table update that a user expects resulting in a watch query not updating when it should.It will also only clear pending updates on a successful emission as opposed to previously where it always cleared pending updates even if the
emit
function was not run.