Skip to content

Commit 58e063b

Browse files
authored
ci: fixing contract test breaking due to async hooks (#1391)
BEGIN_COMMIT_OVERRIDE ci: fixing contract test breaking due to async hooks fix(sdk-client): `executeAfterTrack` ordering END_COMMIT_OVERRIDE <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Changes runtime hook invocation order for afterTrack (a behavioral API contract); impact is limited to apps using multiple track hooks, but ordering semantics are intentional for harness alignment. > > **Overview** > Fixes contract-test hook ordering failures by aligning **`afterTrack`** execution with registration order and serializing harness callback posts. > > In **`HookRunner`**, **`executeAfterTrack`** now iterates hooks forward (same as **`beforeEvaluation`** / **`beforeIdentify`**) instead of reverse like **`afterEvaluation`**. **`HookRunner`** unit expectations for track hook order are updated accordingly. > > Contract-test **`TestHook`** instances now share a **`HookPostQueue`** via **`TestHook.forClient`**, chaining async **`fetch`** callbacks so the harness sees stable arrival order; **`BaseTestHook`** routes evaluation/track posts through **`enqueuePost`**. Browser, Electron, React, React Native, and server-node contract entities use the factory. Hook-order-related lines are removed from several **`suppressions.txt`** files now that behavior matches the harness. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 6b89ddf. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent 7c73024 commit 58e063b

16 files changed

Lines changed: 50 additions & 35 deletions

File tree

packages/sdk/browser/contract-tests/entity/src/ClientEntity.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,9 +190,7 @@ function makeSdkConfig(options: SDKConfigParams, tag: string) {
190190
}
191191

192192
if (options.hooks) {
193-
cf.hooks = options.hooks.hooks.map(
194-
(hook) => new TestHook(hook.name, hook.callbackUri, hook.data, hook.errors),
195-
);
193+
cf.hooks = TestHook.forClient(options.hooks.hooks);
196194
}
197195

198196
cf.fetchGoals = false;

packages/sdk/browser/contract-tests/suppressions.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,4 @@ tags/stream requests/{"applicationId":"._-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKL
1515
tags/stream requests/{"applicationId":"________________________________________________________________","applicationVersion":null}
1616
tags/stream requests/{"applicationId":"________________________________________________________________","applicationVersion":""}
1717
tags/stream requests/{"applicationId":"________________________________________________________________","applicationVersion":"._-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ012345678"}
18-
tags/stream requests/{"applicationId":"________________________________________________________________","applicationVersion":"________________________________________________________________"}
19-
hooks/evaluation/executes beforeEvaluation hooks in registration order
20-
hooks/track/executes afterTrack hooks in registration order
18+
tags/stream requests/{"applicationId":"________________________________________________________________","applicationVersion":"________________________________________________________________"}

packages/sdk/electron/contract-tests/entity/src/ClientEntity.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,7 @@ function makeSdkConfig(options: SDKConfigParams, tag: string) {
8787
}
8888

8989
if (options.hooks) {
90-
cf.hooks = options.hooks.hooks.map(
91-
(hook) => new TestHook(hook.name, hook.callbackUri, hook.data, hook.errors),
92-
);
90+
cf.hooks = TestHook.forClient(options.hooks.hooks);
9391
}
9492

9593
if (options.tls) {
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +0,0 @@
1-
hooks/evaluation/executes beforeEvaluation hooks in registration order
2-
hooks/track/executes afterTrack hooks in registration order

packages/sdk/react-native/contract-tests/entity/src/ClientEntity.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,7 @@ function makeSdkConfig(options: SDKConfigParams, tag: string) {
7777
}
7878

7979
if (options.hooks) {
80-
cf.hooks = options.hooks.hooks.map(
81-
(hook) => new TestHook(hook.name, hook.callbackUri, hook.data, hook.errors),
82-
);
80+
cf.hooks = TestHook.forClient(options.hooks.hooks);
8381
}
8482

8583
return cf;

packages/sdk/react/contract-tests/app/ClientEntity.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,7 @@ export function makeSdkConfig(options: SDKConfigParams, tag: string): LDOptions
7070
}
7171

7272
if (options.hooks) {
73-
cf.hooks = options.hooks.hooks.map(
74-
(hook) => new TestHook(hook.name, hook.callbackUri, hook.data, hook.errors),
75-
);
73+
cf.hooks = TestHook.forClient(options.hooks.hooks);
7674
}
7775

7876
cf.fetchGoals = false;

packages/sdk/react/contract-tests/suppressions.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,3 @@ tags/stream requests/{"applicationId":"_________________________________________
1616
tags/stream requests/{"applicationId":"________________________________________________________________","applicationVersion":""}
1717
tags/stream requests/{"applicationId":"________________________________________________________________","applicationVersion":"._-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ012345678"}
1818
tags/stream requests/{"applicationId":"________________________________________________________________","applicationVersion":"________________________________________________________________"}
19-
hooks/evaluation/executes beforeEvaluation hooks in registration order
20-
hooks/track/executes afterTrack hooks in registration order

packages/sdk/server-node/contract-tests/src/sdkClientEntity.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,7 @@ export function makeSdkConfig(options: ServerSDKConfigParams, tag: string): LDOp
8888
}
8989

9090
if (options.hooks) {
91-
cf.hooks = options.hooks.hooks.map(
92-
(hook) => new TestHook(hook.name, hook.callbackUri, hook.data, hook.errors),
93-
);
91+
cf.hooks = TestHook.forClient(options.hooks.hooks);
9492
}
9593

9694
if (options.wrapper) {

packages/sdk/server-node/contract-tests/testharness-suppressions-fdv2.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,3 @@ streaming/fdv2/reconnection state management/replaces previously known state
1111
streaming/fdv2/reconnection state management/updates previously known state
1212
streaming/fdv2/ignores model version
1313
streaming/fdv2/can discard partial events on errors
14-
hooks/evaluation/executes beforeEvaluation hooks in registration order
15-
hooks/track/executes afterTrack hooks in registration order

packages/sdk/server-node/contract-tests/testharness-suppressions.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,4 @@ streaming/validation/drop and reconnect if stream event has well-formed JSON not
33
streaming/requests/URL path is computed correctly/environment_filter_key="encoding_not_necessary"/base URI has no trailing slash/GET
44
streaming/requests/URL path is computed correctly/environment_filter_key="encoding_not_necessary"/base URI has a trailing slash/GET
55
polling/requests/URL path is computed correctly/environment_filter_key="encoding_not_necessary"/base URI has no trailing slash/GET
6-
polling/requests/URL path is computed correctly/environment_filter_key="encoding_not_necessary"/base URI has a trailing slash/GET
7-
hooks/evaluation/executes beforeEvaluation hooks in registration order
8-
hooks/track/executes afterTrack hooks in registration order
6+
polling/requests/URL path is computed correctly/environment_filter_key="encoding_not_necessary"/base URI has a trailing slash/GET

0 commit comments

Comments
 (0)