apify-client 3.0.0-beta.85 → 3.0.0-beta.86

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -102,7 +102,7 @@ export class ResourceClient extends ApiClient {
102
102
  const hasJobEnded = job && ACT_JOB_TERMINAL_STATUSES.includes(job.status);
103
103
  return !hasJobEnded;
104
104
  };
105
- do {
105
+ while (true) {
106
106
  const millisSinceStart = Date.now() - startedAt;
107
107
  const remainingWaitSeconds = Math.round((waitMillis - millisSinceStart) / 1000);
108
108
  const waitForFinish = Math.max(0, remainingWaitSeconds);
@@ -124,13 +124,13 @@ export class ResourceClient extends ApiClient {
124
124
  notFoundSince ??= Date.now();
125
125
  notFoundError = err;
126
126
  }
127
- // It might take some time for database replicas to get up-to-date,
128
- // so getRun() might return null. Wait a little bit and try it again.
129
- if (!job) {
130
- await sleep(250, signal);
131
- signal?.throwIfAborted();
132
- }
133
- } while (shouldRepeat());
127
+ if (!shouldRepeat())
128
+ break;
129
+ // The API answers right away when the remaining wait rounds to 0 seconds, and database replicas may not see
130
+ // a new job for a short while, so pause before the next poll.
131
+ await sleep(250, signal);
132
+ signal?.throwIfAborted();
133
+ }
134
134
  if (!job)
135
135
  throw notFoundError;
136
136
  return job;