diff --git a/__tests__/functional/feed-client-configuration.test.ts b/__tests__/functional/feed-client-configuration.test.ts index a0c25069..7c190e5b 100644 --- a/__tests__/functional/feed-client-configuration.test.ts +++ b/__tests__/functional/feed-client-configuration.test.ts @@ -97,4 +97,16 @@ describe("FeedClientConfiguration", () => { expect(e).toBeInstanceOf(RangeError); } }); + + it("throws a TypeError if 'cursor' is not a string", async () => { + const config = { ...defaultConfig, cursor: null }; + try { + new FeedClient( + dummyStreamToken, + config as unknown as FeedClientConfiguration, + ); + } catch (e: any) { + expect(e).toBeInstanceOf(TypeError); + } + }); }); diff --git a/src/client.ts b/src/client.ts index c54ebca0..a3644d9e 100644 --- a/src/client.ts +++ b/src/client.ts @@ -1152,6 +1152,10 @@ export class FeedClient { "Only one of 'start_ts' or 'cursor' can be defined in the client configuration.", ); } + + if (config.cursor !== undefined && typeof config.cursor !== "string") { + throw new TypeError("'cursor' must be a string."); + } } }