diff --git a/packages/client.api/src/objectSet/ObjectSet.ts b/packages/client.api/src/objectSet/ObjectSet.ts index cd95ce2ba..69ed2c10b 100644 --- a/packages/client.api/src/objectSet/ObjectSet.ts +++ b/packages/client.api/src/objectSet/ObjectSet.ts @@ -51,6 +51,7 @@ export interface MinimalObjectSet S extends NullabilityAdherence = NullabilityAdherenceDefault, >( args?: FetchPageArgs, + calledByAsyncIter?: boolean, ) => Promise>; fetchPageWithErrors: < diff --git a/packages/client/src/object/fetchPage.ts b/packages/client/src/object/fetchPage.ts index d9fcd0d10..f7a168287 100644 --- a/packages/client/src/object/fetchPage.ts +++ b/packages/client/src/object/fetchPage.ts @@ -41,6 +41,7 @@ import type { import { OntologiesV2 } from "@osdk/internal.foundry"; import type { MinimalClient } from "../MinimalClientContext.js"; import { addUserAgentAndRequestContextHeaders } from "../util/addUserAgentAndRequestContextHeaders.js"; +import { augmentRequestContext } from "../util/augmentRequestContext.js"; import { convertWireToOsdkObjects } from "./convertWireToOsdkObjects.js"; export function augment< @@ -129,11 +130,25 @@ export async function fetchPageInternal< objectType: Q, objectSet: ObjectSet, args: FetchPageArgs = {}, + calledByAsyncIter: boolean = false, ): Promise> { + const modifiedClient = calledByAsyncIter + ? augmentRequestContext(client, _ => ({ finalMethodCall: "asyncIter" })) + : client; if (objectType.type === "interface") { - return await fetchInterfacePage(client, objectType, args, objectSet) as any; // fixme + return await fetchInterfacePage( + modifiedClient, + objectType, + args, + objectSet, + ) as any; // fixme } else { - return await fetchObjectPage(client, objectType, args, objectSet) as any; // fixme + return await fetchObjectPage( + modifiedClient, + objectType, + args, + objectSet, + ) as any; // fixme } } diff --git a/packages/client/src/objectSet/createObjectSet.ts b/packages/client/src/objectSet/createObjectSet.ts index 7f997cfb3..a3f891f4b 100644 --- a/packages/client/src/objectSet/createObjectSet.ts +++ b/packages/client/src/objectSet/createObjectSet.ts @@ -145,8 +145,7 @@ export function createObjectSet( asyncIter: async function*(): AsyncIterableIterator> { let $nextPageToken: string | undefined = undefined; do { - // TODO: figure out how to mark asyncIter-originated fetchPage requests - const result = await base.fetchPage({ $nextPageToken }); + const result = await base.fetchPage({ $nextPageToken }, true); for (const obj of result.data) { yield obj as Osdk;