Skip to content

Conversation

@anthonyting
Copy link
Contributor

@anthonyting anthonyting commented Dec 17, 2025

Issue #, if available:

Description of changes:

There is a race condition in waitForStatusChange where if the operation completes before this is called, it will not get the status and just terminate without updating the data correctly. This results in the error Cannot return PENDING status with no pending operations.

To fix this, if the operation status is terminal in waitForStatusChange or waitForRetryTimer, we resolve instantly instead of creating a promise and waiting.

This can happen since waitForStatusChange is called asynchronously, so there can be time between when the phase 2 promise starts and when the last checkpoint data was updated. I disabled time skipping in wait-for-callback-serdes.test.ts which consistently shows this (when running locally). In the cloud tests it's harder to reproduce since we poll for the callback ID every second and we don't get the data instantly, but it could still happen in rare cases.

I also added this same safeguard for waitForRetryTimer. This could happen if the main thread is blocked for a long time somehow and it fails to call waitForRetryTimer in time.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@anthonyting anthonyting marked this pull request as ready for review December 17, 2025 00:46
@anthonyting anthonyting merged commit 8d49cff into main Dec 17, 2025
11 checks passed
@anthonyting anthonyting deleted the fix/sdk-race-condition branch December 17, 2025 02:16
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