Skip to content

Commit 239ebbc

Browse files
committed
- Update new tests to be v5 only
- Try cloning fetch to prevent 502/503
1 parent 12a3b89 commit 239ebbc

4 files changed

Lines changed: 18 additions & 10 deletions

File tree

src/integration-tests/E2EFiveTaskWorkflow.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import {
22
afterEach,
33
beforeAll,
4-
describe,
54
expect,
65
jest,
76
test,
@@ -18,8 +17,9 @@ import {
1817
} from "../sdk";
1918
import { cleanupWorkflowsAndTasks } from "./utils/cleanup";
2019
import { waitForWorkflowStatus } from "./utils/waitForWorkflowStatus";
20+
import { describeForOrkesV5 } from "./utils/customJestDescribe";
2121

22-
describe("E2E: 5-task workflow × 50 executions", () => {
22+
describeForOrkesV5("E2E: 5-task workflow × 50 executions", () => {
2323
const clientPromise: Promise<Client> = orkesConductorClient();
2424
let executor: WorkflowExecutor;
2525
let handler: TaskHandler | undefined;

src/integration-tests/PromptClient.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@ import {
55
PromptClient,
66
} from "../sdk";
77
import type { Tag } from "../open-api";
8+
import { describeForOrkesV5 } from "./utils/customJestDescribe";
89

910
/**
10-
* E2E Integration Tests for PromptClient
11+
* E2E Integration Tests for PromptClient (v5 only).
1112
*
1213
* Tests prompt CRUD, tag management, and (optionally) prompt testing
1314
* against a configured LLM integration.
1415
*/
15-
describe("PromptClient", () => {
16+
describeForOrkesV5("PromptClient", () => {
1617
jest.setTimeout(60000);
1718

1819
const clientPromise = orkesConductorClient();

src/integration-tests/WorkerAdvanced.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,18 @@ import {
2424
import { cleanupWorkflowsAndTasks } from "./utils/cleanup";
2525
import { waitForWorkflowStatus } from "./utils/waitForWorkflowStatus";
2626
import { executeWorkflowWithRetry } from "./utils/executeWorkflowWithRetry";
27+
import { describeForOrkesV5 } from "./utils/customJestDescribe";
2728

2829
/**
29-
* E2E Integration Tests for Advanced Worker Features
30+
* E2E Integration Tests for Advanced Worker Features (v5 only).
3031
*
3132
* Tests features not covered in WorkerRegistration.test.ts:
3233
* - MetricsCollector — verify metrics collected during workflow execution
3334
* - MetricsServer — start on port, scrape /metrics and /health
3435
* - TaskContext — getTaskContext(), addLog(), verify logs via getTaskLogs()
3536
* - Worker with paused option
3637
*/
37-
describe("Worker Advanced Features", () => {
38+
describeForOrkesV5("Worker Advanced Features", () => {
3839
jest.setTimeout(120000);
3940

4041
const clientPromise = orkesConductorClient();

src/sdk/createConductorClient/helpers/fetchWithRetry.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,13 +129,19 @@ export const retryFetch = async (
129129
const getInit = (): Init =>
130130
requestTimeoutMs ? applyTimeout(init, requestTimeoutMs) : init ?? {};
131131

132+
/** Fresh request per attempt — reusing a Request whose body was already consumed causes "body disturbed or locked" on retry (e.g. 502/503/504 in CI). */
133+
const getRequest = (): Input =>
134+
typeof input === "object" && input !== null && "clone" in input && typeof (input as Request).clone === "function"
135+
? (input as Request).clone()
136+
: input;
137+
132138
let lastError: unknown;
133139

134140
// Transport retry loop
135141
for (let transportAttempt = 0; transportAttempt <= maxTransportRetries; transportAttempt++) {
136142
let response: Response;
137143
try {
138-
response = cloneResponse(await fetchFn(input, getInit()));
144+
response = cloneResponse(await fetchFn(getRequest(), getInit()));
139145
} catch (error) {
140146
// Timeout/abort errors should NOT be retried
141147
if (isTimeoutError(error)) {
@@ -158,7 +164,7 @@ export const retryFetch = async (
158164
await new Promise((resolve) =>
159165
setTimeout(resolve, withJitter(initialRetryDelay * (gwAttempt + 1)))
160166
);
161-
response = cloneResponse(await fetchFn(input, getInit()));
167+
response = cloneResponse(await fetchFn(getRequest(), getInit()));
162168
}
163169

164170
// Rate limit retry (429)
@@ -167,7 +173,7 @@ export const retryFetch = async (
167173
let delay = initialRetryDelay;
168174
for (let rlAttempt = 0; rlAttempt < maxRateLimitRetries; rlAttempt++) {
169175
await new Promise((resolve) => setTimeout(resolve, withJitter(delay)));
170-
rateLimitResponse = cloneResponse(await fetchFn(input, getInit()));
176+
rateLimitResponse = cloneResponse(await fetchFn(getRequest(), getInit()));
171177
if (rateLimitResponse.status !== 429) {
172178
return rateLimitResponse;
173179
}
@@ -191,7 +197,7 @@ export const retryFetch = async (
191197
headers: new Headers(init?.headers),
192198
};
193199
retryInit.headers.set("X-Authorization", newToken);
194-
return cloneResponse(await fetchFn(input, retryInit));
200+
return cloneResponse(await fetchFn(getRequest(), retryInit));
195201
}
196202
}
197203

0 commit comments

Comments
 (0)