Skip to content

Commit

Permalink
[FIX] jetstreamManager(checkAPI) overrode the checkAPI option incorre…
Browse files Browse the repository at this point in the history
…ctly.
  • Loading branch information
aricart committed Mar 26, 2024
1 parent 109f77a commit b3b9133
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
8 changes: 6 additions & 2 deletions jetstream/jsclient.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2022-2023 The NATS Authors
* Copyright 2022-2024 The NATS Authors
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
Expand Down Expand Up @@ -159,9 +159,13 @@ export class JetStreamClientImpl extends BaseApiClient
}

jetstreamManager(checkAPI?: boolean): Promise<JetStreamManager> {
if (checkAPI === undefined) {
checkAPI = (this.opts as JetStreamManagerOptions).checkAPI;
}
const opts = Object.assign(
{ checkAPI },
{},
this.opts,
{ checkAPI },
) as JetStreamManagerOptions;
return this.nc.jetstreamManager(opts);
}
Expand Down
7 changes: 4 additions & 3 deletions jetstream/tests/jsm_test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2021-2023 The NATS Authors
* Copyright 2021-2024 The NATS Authors
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
Expand Down Expand Up @@ -2712,7 +2712,8 @@ Deno.test("jsm - api check not ok", async () => {
await nc.jetstream().jetstreamManager(false);
await nc.jetstream({ checkAPI: false }).jetstreamManager();
await nc.jetstream({ checkAPI: false }).jetstreamManager(true);
assertEquals(count, 0);
await nc.jetstream().jetstreamManager();
assertEquals(count, 2);

await cleanup(ns, nc);
});
Expand All @@ -2732,7 +2733,7 @@ Deno.test("jsm - api check ok", async () => {
await nc.jetstream({ checkAPI: true }).jetstreamManager();
await nc.jetstream({ checkAPI: true }).jetstreamManager(false);

assertEquals(count, 3);
assertEquals(count, 4);
await cleanup(ns, nc);
});

Expand Down

0 comments on commit b3b9133

Please sign in to comment.