Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

request validation doesn't reject properly in downstream #216

Merged
merged 1 commit into from
Nov 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion nats-base-client/nats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,11 @@ export class NatsConnectionImpl implements NatsConnection {
data: Uint8Array = Empty,
opts: RequestOptions = { timeout: 1000, noMux: false },
): Promise<Msg> {
this._check(subject, true, true);
try {
this._check(subject, true, true);
} catch (err) {
return Promise.reject(err);
}
opts.timeout = opts.timeout || 1000;
if (opts.timeout < 1) {
return Promise.reject(new NatsError("timeout", ErrorCode.InvalidOption));
Expand Down
2 changes: 1 addition & 1 deletion src/deno_transport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import {
} from "../nats-base-client/internal_mod.ts";
import type { TlsOptions } from "../nats-base-client/types.ts";

const VERSION = "1.3.0";
const VERSION = "1.3.1";
const LANG = "nats.deno";

// if trying to simply write to the connection for some reason
Expand Down
13 changes: 13 additions & 0 deletions tests/basics_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,19 @@ Deno.test("basics - request with custom subject", async () => {
await cleanup(ns, nc);
});

Deno.test("basics - request requires a subject", async () => {
const { ns, nc } = await setup();
await assertThrowsAsync(
async () => {
//@ts-ignore: subject missing on purpose
await nc.request();
},
NatsError,
"BAD_SUBJECT",
);
await cleanup(ns, nc);
});

Deno.test("basics - close promise resolves", async () => {
const lock = Lock();
const cs = new TestServer(false, (ca: Connection) => {
Expand Down