Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@nats-io/jetstream

Package Overview
Dependencies
Maintainers
0
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nats-io/jetstream - npm Package Compare versions

Comparing version 3.0.0-15 to 3.0.0-16

lib/jserrors.d.ts

14

lib/consumer.d.ts

@@ -1,2 +0,2 @@

import type { CallbackFn, Delay, MsgHdrs, QueuedIterator, Status, Subscription, Timeout } from "@nats-io/nats-core/internal";
import type { CallbackFn, Delay, QueuedIterator, Status, Subscription, Timeout } from "@nats-io/nats-core/internal";
import { IdleHeartbeatMonitor, QueuedIteratorImpl } from "@nats-io/nats-core/internal";

@@ -6,4 +6,5 @@ import type { ConsumerAPIImpl } from "./jsmconsumer_api";

import type { ConsumerConfig, ConsumerInfo, PullOptions } from "./jsapi_types";
import type { ConsumeOptions, Consumer, ConsumerAPI, ConsumerCallbackFn, ConsumerMessages, ConsumerStatus, FetchOptions, NextOptions, OrderedConsumerOptions, PullConsumerOptions } from "./types";
import { ConsumerDebugEvents, ConsumerEvents } from "./types";
import type { ConsumeOptions, Consumer, ConsumerAPI, ConsumerCallbackFn, ConsumerMessages, ConsumerStatus, FetchOptions, NextOptions, OrderedConsumerOptions, PullConsumerOptions } from "./types";
import { JetStreamStatus } from "./jserrors";
declare enum PullConsumerType {

@@ -56,6 +57,5 @@ Unset = -1,

* it should reject the operation by returning an Error or null
* @param code
* @param description
* @param JetStreamStatus
*/
handle409(code: number, description: string): Error | null;
handle409(status: JetStreamStatus): Error | null;
reset(): void;

@@ -69,6 +69,2 @@ _push(r: JsMsg | CallbackFn): void;

pullOptions(): Partial<PullOptions>;
parseDiscard(headers?: MsgHdrs): {
msgsLeft: number;
bytesLeft: number;
};
trackTimeout(t: Timeout<unknown>): void;

@@ -75,0 +71,0 @@ close(): Promise<void | Error>;

@@ -19,6 +19,6 @@ "use strict";

const internal_1 = require("@nats-io/nats-core/internal");
const jsutil_1 = require("./jsutil");
const jsmsg_1 = require("./jsmsg");
const jsapi_types_1 = require("./jsapi_types");
const types_1 = require("./types");
const jserrors_1 = require("./jserrors");
var PullConsumerType;

@@ -95,16 +95,13 @@ (function (PullConsumerType) {

if (isProtocol) {
if ((0, jsutil_1.isHeartbeatMsg)(msg)) {
const natsLastConsumer = msg.headers?.get("Nats-Last-Consumer");
const natsLastStream = msg.headers?.get("Nats-Last-Stream");
this.notify(types_1.ConsumerDebugEvents.Heartbeat, {
natsLastConsumer,
natsLastStream,
});
const status = new jserrors_1.JetStreamStatus(msg);
status.debug();
if (status.isIdleHeartbeat()) {
this.notify(types_1.ConsumerDebugEvents.Heartbeat, status.parseHeartbeat());
return;
}
const code = msg.headers?.code;
const description = msg.headers?.description?.toLowerCase() ||
"unknown";
const { msgsLeft, bytesLeft } = this.parseDiscard(msg.headers);
if (msgsLeft > 0 || bytesLeft > 0) {
const code = status.code;
const description = status.description;
const { msgsLeft, bytesLeft } = status.parseDiscard();
console.log("pending", msgsLeft, bytesLeft);
if ((msgsLeft && msgsLeft > 0) || (bytesLeft && bytesLeft > 0)) {
this.pending.msgs -= msgsLeft;

@@ -127,6 +124,6 @@ this.pending.bytes -= bytesLeft;

case 400:
this.stop(new internal_1.NatsError(description, `${code}`));
this.stop(status.toError());
return;
case 409: {
const err = this.handle409(code, description);
const err = this.handle409(status);
if (err) {

@@ -254,17 +251,17 @@ this.stop(err);

* it should reject the operation by returning an Error or null
* @param code
* @param description
* @param JetStreamStatus
*/
handle409(code, description) {
const e = description === "consumer deleted"
? types_1.ConsumerEvents.ConsumerDeleted
: types_1.ConsumerEvents.ExceededLimit;
this.notify(e, { code, description });
handle409(status) {
const { code, description } = status;
if (status.isConsumerDeleted()) {
this.notify(types_1.ConsumerEvents.ConsumerDeleted, { code, description });
}
else if (status.isExceededLimit()) {
this.notify(types_1.ConsumerEvents.ExceededLimit, { code, description });
}
if (!this.isConsume) {
// terminate the fetch/next
return new internal_1.NatsError(description, `${code}`);
return status.toError();
}
else if (e === types_1.ConsumerEvents.ConsumerDeleted && this.abortOnMissingResource) {
// terminate the consume if abortOnMissingResource
return new internal_1.NatsError(description, `${code}`);
if (status.isConsumerDeleted() && this.abortOnMissingResource) {
return status.toError();
}

@@ -459,17 +456,2 @@ return null;

}
parseDiscard(headers) {
const discard = {
msgsLeft: 0,
bytesLeft: 0,
};
const msgsLeft = headers?.get(types_1.JsHeaders.PendingMessagesHdr);
if (msgsLeft) {
discard.msgsLeft = parseInt(msgsLeft);
}
const bytesLeft = headers?.get(types_1.JsHeaders.PendingBytesHdr);
if (bytesLeft) {
discard.bytesLeft = parseInt(bytesLeft);
}
return discard;
}
trackTimeout(t) {

@@ -476,0 +458,0 @@ this.timeout = t;

@@ -1,2 +0,1 @@

export { checkJsError, isFlowControlMsg, isHeartbeatMsg } from "./jsutil";
export { AdvisoryKind, ConsumerDebugEvents, ConsumerEvents, DirectMsgHeaders, isBoundPushConsumerOptions, isOrderedPushConsumerOptions, isPullConsumer, isPushConsumer, JsHeaders, RepublishHeaders, } from "./types";

@@ -11,1 +10,2 @@ export { jetstream, JetStreamClientImpl, jetstreamManager, toJetStreamClient, } from "./jsclient";

export { ListerImpl } from "./jslister";
export { JetStreamApiCodes, JetStreamApiError, JetStreamError, } from "./jserrors";
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ListerImpl = exports.StoreCompression = exports.StorageType = exports.RetentionPolicy = exports.ReplayPolicy = exports.PubHeaders = exports.DiscardPolicy = exports.DeliverPolicy = exports.AckPolicy = exports.toJetStreamClient = exports.jetstreamManager = exports.JetStreamClientImpl = exports.jetstream = exports.RepublishHeaders = exports.JsHeaders = exports.isPushConsumer = exports.isPullConsumer = exports.isOrderedPushConsumerOptions = exports.isBoundPushConsumerOptions = exports.DirectMsgHeaders = exports.ConsumerEvents = exports.ConsumerDebugEvents = exports.AdvisoryKind = exports.isHeartbeatMsg = exports.isFlowControlMsg = exports.checkJsError = void 0;
/*

@@ -18,6 +16,4 @@ * Copyright 2023-2024 The NATS Authors

*/
var jsutil_1 = require("./jsutil");
Object.defineProperty(exports, "checkJsError", { enumerable: true, get: function () { return jsutil_1.checkJsError; } });
Object.defineProperty(exports, "isFlowControlMsg", { enumerable: true, get: function () { return jsutil_1.isFlowControlMsg; } });
Object.defineProperty(exports, "isHeartbeatMsg", { enumerable: true, get: function () { return jsutil_1.isHeartbeatMsg; } });
Object.defineProperty(exports, "__esModule", { value: true });
exports.JetStreamError = exports.JetStreamApiError = exports.JetStreamApiCodes = exports.ListerImpl = exports.StoreCompression = exports.StorageType = exports.RetentionPolicy = exports.ReplayPolicy = exports.PubHeaders = exports.DiscardPolicy = exports.DeliverPolicy = exports.AckPolicy = exports.toJetStreamClient = exports.jetstreamManager = exports.JetStreamClientImpl = exports.jetstream = exports.RepublishHeaders = exports.JsHeaders = exports.isPushConsumer = exports.isPullConsumer = exports.isOrderedPushConsumerOptions = exports.isBoundPushConsumerOptions = exports.DirectMsgHeaders = exports.ConsumerEvents = exports.ConsumerDebugEvents = exports.AdvisoryKind = void 0;
var types_1 = require("./types");

@@ -50,2 +46,6 @@ Object.defineProperty(exports, "AdvisoryKind", { enumerable: true, get: function () { return types_1.AdvisoryKind; } });

Object.defineProperty(exports, "ListerImpl", { enumerable: true, get: function () { return jslister_1.ListerImpl; } });
var jserrors_1 = require("./jserrors");
Object.defineProperty(exports, "JetStreamApiCodes", { enumerable: true, get: function () { return jserrors_1.JetStreamApiCodes; } });
Object.defineProperty(exports, "JetStreamApiError", { enumerable: true, get: function () { return jserrors_1.JetStreamApiError; } });
Object.defineProperty(exports, "JetStreamError", { enumerable: true, get: function () { return jserrors_1.JetStreamError; } });
//# sourceMappingURL=internal_mod.js.map

@@ -1,2 +0,2 @@

import type { ApiError, Nanos } from "@nats-io/nats-core";
import type { Nanos } from "@nats-io/nats-core";
export interface ApiPaged {

@@ -14,2 +14,16 @@ total: number;

}
export interface ApiError {
/**
* HTTP like error code in the 300 to 500 range
*/
code: number;
/**
* A human friendly description of the error
*/
description: string;
/**
* The NATS error code unique to each kind of error
*/
err_code: number;
}
/**

@@ -16,0 +30,0 @@ * An alternate location to read mirrored data

@@ -20,3 +20,3 @@ "use strict";

const internal_1 = require("@nats-io/nats-core/internal");
const jsutil_1 = require("./jsutil");
const jserrors_1 = require("./jserrors");
const defaultPrefix = "$JS.API";

@@ -75,4 +75,6 @@ const defaultTimeout = 5000;

catch (err) {
const ne = err;
if ((ne.code === "503" || ne.code === internal_1.ErrorCode.Timeout) &&
const { cause } = err;
if (err instanceof internal_1.RequestError &&
(cause instanceof internal_1.TimeoutError ||
cause instanceof internal_1.NoRespondersError) &&
i + 1 < retries) {

@@ -103,10 +105,3 @@ await (0, internal_1.delay)(bo.backoff(i));

if (r.error) {
const err = (0, jsutil_1.checkJsErrorCode)(r.error.code, r.error.description);
if (err !== null) {
err.api_error = r.error;
if (r.error.description !== "") {
err.message = r.error.description;
}
throw err;
}
throw new jserrors_1.JetStreamApiError(r.error);
}

@@ -113,0 +108,0 @@ return v;

@@ -28,2 +28,3 @@ "use strict";

const jsm_1 = require("./jsm");
const jserrors_1 = require("./jserrors");
function toJetStreamClient(nc) {

@@ -56,7 +57,6 @@ //@ts-ignore: see if we have a nc

catch (err) {
const ne = err;
if (ne.code === internal_2.ErrorCode.NoResponders) {
ne.code = internal_2.ErrorCode.JetStreamNotEnabled;
if (err instanceof internal_2.RequestError && err.message.includes("no responders")) {
throw new jserrors_1.JetStreamError("jetstream is not enabled", err);
}
throw ne;
throw new jserrors_1.JetStreamError(err.message, err);
}

@@ -167,4 +167,3 @@ }

catch (err) {
const ne = err;
if (ne.code === "503" && i + 1 < retries) {
if (err instanceof internal_2.RequestError && err.message.includes("no responders")) {
await (0, internal_1.delay)(retry_delay);

@@ -179,3 +178,3 @@ }

if (pa.stream === "") {
throw internal_1.NatsError.errorForCode(internal_2.ErrorCode.JetStreamInvalidAck);
throw new jserrors_1.JetStreamError("invalid ack response");
}

@@ -182,0 +181,0 @@ pa.duplicate = pa.duplicate ? pa.duplicate : false;

@@ -22,2 +22,3 @@ "use strict";

const jsutil_1 = require("./jsutil");
const jserrors_1 = require("./jserrors");
class DirectStreamAPIImpl extends jsbaseclient_api_1.BaseApiClientImpl {

@@ -42,6 +43,14 @@ constructor(nc, opts) {

const r = await this.nc.request(subj, payload);
// response is not a JS.API response
const err = (0, jsutil_1.checkJsError)(r);
if (err) {
return Promise.reject(err);
if (r.headers?.code !== 0) {
const status = new jserrors_1.JetStreamStatus(r);
if (status.isMessageNotFound()) {
// this so to simplify things that handle a non-existing messages
// as null (such as KV).
return Promise.reject(new jserrors_1.JetStreamApiError({
code: status.code,
err_code: jserrors_1.JetStreamApiCodes.NoMessageFound,
description: status.description,
}));
}
return Promise.reject(status.toError());
}

@@ -48,0 +57,0 @@ const dm = new DirectMsgImpl(r);

@@ -43,3 +43,3 @@ import type { Msg, MsgHdrs } from "@nats-io/nats-core/internal";

* Indicate to the JetStream server that processing of the message
* failed, and that it should be resent after the spefied number of
* failed, and that it should be resent after the specified number of
* milliseconds.

@@ -46,0 +46,0 @@ * @param millis

@@ -117,3 +117,3 @@ "use strict";

const r = new internal_1.RequestOne(proto.muxSubscriptions, this.msg.reply, {
timeout: this.timeout,
timeout: opts.timeout,
}, trace);

@@ -120,0 +120,0 @@ proto.request(r);

@@ -1,3 +0,1 @@

import { NatsError } from "@nats-io/nats-core/internal";
import type { Msg } from "@nats-io/nats-core/internal";
export declare function validateDurableName(name?: string): string;

@@ -8,26 +6,1 @@ export declare function validateStreamName(name?: string): string;

export declare function validName(name?: string): string;
/**
* Returns true if the message is a flow control message
* @param msg
*/
export declare function isFlowControlMsg(msg: Msg): boolean;
/**
* Returns true if the message is a heart beat message
* @param msg
*/
export declare function isHeartbeatMsg(msg: Msg): boolean;
export declare function newJsErrorMsg(code: number, description: string, subject: string): Msg;
export declare function checkJsError(msg: Msg): NatsError | null;
export declare enum Js409Errors {
MaxBatchExceeded = "exceeded maxrequestbatch of",
MaxExpiresExceeded = "exceeded maxrequestexpires of",
MaxBytesExceeded = "exceeded maxrequestmaxbytes of",
MaxMessageSizeExceeded = "message size exceeds maxbytes",
PushConsumer = "consumer is push based",
MaxWaitingExceeded = "exceeded maxwaiting",// not terminal
IdleHeartbeatMissed = "idle heartbeats missed",
ConsumerDeleted = "consumer deleted"
}
export declare function setMaxWaitingToFail(tf: boolean): void;
export declare function isTerminal409(err: NatsError): boolean;
export declare function checkJsErrorCode(code: number, description?: string): NatsError | null;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Js409Errors = void 0;
exports.validateDurableName = validateDurableName;
exports.validateStreamName = validateStreamName;
exports.minValidation = minValidation;
exports.validateName = validateName;
exports.validName = validName;
exports.isFlowControlMsg = isFlowControlMsg;
exports.isHeartbeatMsg = isHeartbeatMsg;
exports.newJsErrorMsg = newJsErrorMsg;
exports.checkJsError = checkJsError;
exports.setMaxWaitingToFail = setMaxWaitingToFail;
exports.isTerminal409 = isTerminal409;
exports.checkJsErrorCode = checkJsErrorCode;
/*

@@ -30,3 +16,8 @@ * Copyright 2021-2024 The NATS Authors

*/
const internal_1 = require("@nats-io/nats-core/internal");
Object.defineProperty(exports, "__esModule", { value: true });
exports.validateDurableName = validateDurableName;
exports.validateStreamName = validateStreamName;
exports.minValidation = minValidation;
exports.validateName = validateName;
exports.validName = validName;
function validateDurableName(name) {

@@ -90,109 +81,2 @@ return minValidation("durable", name);

}
/**
* Returns true if the message is a flow control message
* @param msg
*/
function isFlowControlMsg(msg) {
if (msg.data.length > 0) {
return false;
}
const h = msg.headers;
if (!h) {
return false;
}
return h.code >= 100 && h.code < 200;
}
/**
* Returns true if the message is a heart beat message
* @param msg
*/
function isHeartbeatMsg(msg) {
return isFlowControlMsg(msg) && msg.headers?.description === "Idle Heartbeat";
}
function newJsErrorMsg(code, description, subject) {
const h = (0, internal_1.headers)(code, description);
const arg = { hdr: 1, sid: 0, size: 0 };
const msg = new internal_1.MsgImpl(arg, internal_1.Empty, {});
msg._headers = h;
msg._subject = subject;
return msg;
}
function checkJsError(msg) {
// JS error only if no payload - otherwise assume it is application data
if (msg.data.length !== 0) {
return null;
}
const h = msg.headers;
if (!h) {
return null;
}
return checkJsErrorCode(h.code, h.description);
}
var Js409Errors;
(function (Js409Errors) {
Js409Errors["MaxBatchExceeded"] = "exceeded maxrequestbatch of";
Js409Errors["MaxExpiresExceeded"] = "exceeded maxrequestexpires of";
Js409Errors["MaxBytesExceeded"] = "exceeded maxrequestmaxbytes of";
Js409Errors["MaxMessageSizeExceeded"] = "message size exceeds maxbytes";
Js409Errors["PushConsumer"] = "consumer is push based";
Js409Errors["MaxWaitingExceeded"] = "exceeded maxwaiting";
Js409Errors["IdleHeartbeatMissed"] = "idle heartbeats missed";
Js409Errors["ConsumerDeleted"] = "consumer deleted";
// FIXME: consumer deleted - instead of no responder (terminal error)
// leadership changed -
})(Js409Errors || (exports.Js409Errors = Js409Errors = {}));
let MAX_WAITING_FAIL = false;
function setMaxWaitingToFail(tf) {
MAX_WAITING_FAIL = tf;
}
function isTerminal409(err) {
if (err.code !== internal_1.ErrorCode.JetStream409) {
return false;
}
const fatal = [
Js409Errors.MaxBatchExceeded,
Js409Errors.MaxExpiresExceeded,
Js409Errors.MaxBytesExceeded,
Js409Errors.MaxMessageSizeExceeded,
Js409Errors.PushConsumer,
Js409Errors.IdleHeartbeatMissed,
Js409Errors.ConsumerDeleted,
];
if (MAX_WAITING_FAIL) {
fatal.push(Js409Errors.MaxWaitingExceeded);
}
return fatal.find((s) => {
return err.message.indexOf(s) !== -1;
}) !== undefined;
}
function checkJsErrorCode(code, description = "") {
if (code < 300) {
return null;
}
description = description.toLowerCase();
switch (code) {
case 404:
// 404 for jetstream will provide different messages ensure we
// keep whatever the server returned
return new internal_1.NatsError(description, internal_1.ErrorCode.JetStream404NoMessages);
case 408:
return new internal_1.NatsError(description, internal_1.ErrorCode.JetStream408RequestTimeout);
case 409: {
// the description can be exceeded max waiting or max ack pending, which are
// recoverable, but can also be terminal errors where the request exceeds
// some value in the consumer configuration
const ec = description.startsWith(Js409Errors.IdleHeartbeatMissed)
? internal_1.ErrorCode.JetStreamIdleHeartBeat
: internal_1.ErrorCode.JetStream409;
return new internal_1.NatsError(description, ec);
}
case 503:
return internal_1.NatsError.errorForCode(internal_1.ErrorCode.JetStreamNotEnabled, new Error(description));
default:
if (description === "") {
description = internal_1.ErrorCode.Unknown;
}
return new internal_1.NatsError(description, `${code}`);
}
}
//# sourceMappingURL=jsutil.js.map

@@ -1,3 +0,3 @@

export { checkJsError, isFlowControlMsg, isHeartbeatMsg, jetstream, jetstreamManager, } from "./internal_mod";
export { AckPolicy, AdvisoryKind, ConsumerDebugEvents, ConsumerEvents, DeliverPolicy, DirectMsgHeaders, DiscardPolicy, isPullConsumer, isPushConsumer, JsHeaders, ReplayPolicy, RepublishHeaders, RetentionPolicy, StorageType, StoreCompression, } from "./internal_mod";
export { jetstream, jetstreamManager } from "./internal_mod";
export { AckPolicy, AdvisoryKind, ConsumerDebugEvents, ConsumerEvents, DeliverPolicy, DirectMsgHeaders, DiscardPolicy, isPullConsumer, isPushConsumer, JetStreamApiCodes, JetStreamApiError, JetStreamError, JsHeaders, ReplayPolicy, RepublishHeaders, RetentionPolicy, StorageType, StoreCompression, } from "./internal_mod";
export type { AbortOnMissingResource, AccountLimits, Advisory, ApiPagedRequest, Bind, BoundPushConsumerOptions, Closed, ClusterInfo, ConsumeBytes, ConsumeCallback, ConsumeMessages, ConsumeOptions, Consumer, ConsumerAPI, ConsumerCallbackFn, ConsumerConfig, ConsumerInfo, ConsumerKind, ConsumerMessages, Consumers, ConsumerStatus, ConsumerUpdateConfig, DeleteableConsumer, DeliveryInfo, Destroyable, Expires, ExternalStream, FetchBytes, FetchMessages, FetchOptions, IdleHeartbeat, InfoableConsumer, JetStreamAccountStats, JetStreamApiStats, JetStreamClient, JetStreamManager, JetStreamManagerOptions, JetStreamOptions, JetStreamPublishOptions, JetStreamUsageAccountLimits, JsMsg, LastForMsgRequest, Lister, LostStreamData, MaxBytes, MaxMessages, MsgDeleteRequest, MsgRequest, NextOptions, OrderedConsumerOptions, OrderedPushConsumerOptions, PeerInfo, Placement, PubAck, PullOptions, PurgeBySeq, PurgeBySubject, PurgeOpts, PurgeResponse, PurgeTrimOpts, PushConsumer, PushConsumerOptions, Republish, SeqMsgRequest, SequenceInfo, StoredMsg, Stream, StreamAlternate, StreamAPI, StreamConfig, StreamConsumerLimits, StreamInfo, StreamInfoRequestOptions, StreamNames, Streams, StreamSource, StreamSourceInfo, StreamState, StreamUpdateConfig, SubjectTransformConfig, ThresholdBytes, ThresholdMessages, } from "./internal_mod";
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.StoreCompression = exports.StorageType = exports.RetentionPolicy = exports.RepublishHeaders = exports.ReplayPolicy = exports.JsHeaders = exports.isPushConsumer = exports.isPullConsumer = exports.DiscardPolicy = exports.DirectMsgHeaders = exports.DeliverPolicy = exports.ConsumerEvents = exports.ConsumerDebugEvents = exports.AdvisoryKind = exports.AckPolicy = exports.jetstreamManager = exports.jetstream = exports.isHeartbeatMsg = exports.isFlowControlMsg = exports.checkJsError = void 0;
exports.StoreCompression = exports.StorageType = exports.RetentionPolicy = exports.RepublishHeaders = exports.ReplayPolicy = exports.JsHeaders = exports.JetStreamError = exports.JetStreamApiError = exports.JetStreamApiCodes = exports.isPushConsumer = exports.isPullConsumer = exports.DiscardPolicy = exports.DirectMsgHeaders = exports.DeliverPolicy = exports.ConsumerEvents = exports.ConsumerDebugEvents = exports.AdvisoryKind = exports.AckPolicy = exports.jetstreamManager = exports.jetstream = void 0;
/*

@@ -19,5 +19,2 @@ * Copyright 2023-2024 The NATS Authors

var internal_mod_1 = require("./internal_mod");
Object.defineProperty(exports, "checkJsError", { enumerable: true, get: function () { return internal_mod_1.checkJsError; } });
Object.defineProperty(exports, "isFlowControlMsg", { enumerable: true, get: function () { return internal_mod_1.isFlowControlMsg; } });
Object.defineProperty(exports, "isHeartbeatMsg", { enumerable: true, get: function () { return internal_mod_1.isHeartbeatMsg; } });
Object.defineProperty(exports, "jetstream", { enumerable: true, get: function () { return internal_mod_1.jetstream; } });

@@ -35,2 +32,5 @@ Object.defineProperty(exports, "jetstreamManager", { enumerable: true, get: function () { return internal_mod_1.jetstreamManager; } });

Object.defineProperty(exports, "isPushConsumer", { enumerable: true, get: function () { return internal_mod_2.isPushConsumer; } });
Object.defineProperty(exports, "JetStreamApiCodes", { enumerable: true, get: function () { return internal_mod_2.JetStreamApiCodes; } });
Object.defineProperty(exports, "JetStreamApiError", { enumerable: true, get: function () { return internal_mod_2.JetStreamApiError; } });
Object.defineProperty(exports, "JetStreamError", { enumerable: true, get: function () { return internal_mod_2.JetStreamError; } });
Object.defineProperty(exports, "JsHeaders", { enumerable: true, get: function () { return internal_mod_2.JsHeaders; } });

@@ -37,0 +37,0 @@ Object.defineProperty(exports, "ReplayPolicy", { enumerable: true, get: function () { return internal_mod_2.ReplayPolicy; } });

@@ -8,3 +8,3 @@ "use strict";

const internal_1 = require("@nats-io/nats-core/internal");
const mod_1 = require("./mod");
const jserrors_1 = require("./jserrors");
class PushConsumerMessagesImpl extends internal_1.QueuedIteratorImpl {

@@ -217,3 +217,4 @@ consumer;

if (isProtocol) {
if ((0, mod_1.isHeartbeatMsg)(msg)) {
const status = new jserrors_1.JetStreamStatus(msg);
if (status.isIdleHeartbeat()) {
const natsLastConsumer = msg.headers?.get("Nats-Last-Consumer");

@@ -227,3 +228,4 @@ const natsLastStream = msg.headers?.get("Nats-Last-Stream");

}
if ((0, mod_1.isFlowControlMsg)(msg)) {
if (status.isFlowControlRequest()) {
status.debug();
this._push(() => {

@@ -235,6 +237,5 @@ msg.respond();

}
const code = msg.headers?.code;
const description = msg.headers?.description?.toLowerCase() ||
"unknown";
if (code === 409 && description === "consumer deleted") {
const code = status.code;
const description = status.description;
if (status.isConsumerDeleted()) {
this.notify(types_1.ConsumerEvents.ConsumerDeleted, `${code} ${description}`);

@@ -244,4 +245,3 @@ }

this._push(() => {
const error = new internal_1.NatsError(description, `${code}`);
this.stop(error);
this.stop(status.toError());
});

@@ -248,0 +248,0 @@ return;

@@ -431,3 +431,3 @@ import type { MsgHdrs, Nanos, Payload, QueuedIterator, ReviverFn } from "@nats-io/nats-core/internal";

* Notifies that the client received a server-side heartbeat. The payload the data
* portion has the format `{natsLastConsumer: string, natsLastStream: string}`;
* portion has the format `{natsLastConsumer: number, natsLastStream: number}`;
*/

@@ -434,0 +434,0 @@ Heartbeat = "heartbeat",

@@ -102,3 +102,3 @@ "use strict";

* Notifies that the client received a server-side heartbeat. The payload the data
* portion has the format `{natsLastConsumer: string, natsLastStream: string}`;
* portion has the format `{natsLastConsumer: number, natsLastStream: number}`;
*/

@@ -105,0 +105,0 @@ ConsumerDebugEvents["Heartbeat"] = "heartbeat";

{
"name": "@nats-io/jetstream",
"version": "3.0.0-15",
"version": "3.0.0-16",
"files": [

@@ -37,3 +37,3 @@ "lib/",

"dependencies": {
"@nats-io/nats-core": "~3.0.0-30"
"@nats-io/nats-core": "~3.0.0-31"
},

@@ -40,0 +40,0 @@ "devDependencies": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc