Skip to content

Commit f25ec63

Browse files
committed
fix: added aggressive connection keepalive timeout
1 parent 551b772 commit f25ec63

5 files changed

Lines changed: 48 additions & 5 deletions

File tree

dist/cjs/index.cjs

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7306,6 +7306,8 @@ var require_dist = __commonJS({
73067306
var index_exports = {};
73077307
__export(index_exports, {
73087308
JackdClient: () => JackdClient,
7309+
JackdError: () => JackdError,
7310+
JackdErrorCode: () => JackdErrorCode,
73097311
default: () => index_default
73107312
});
73117313
module.exports = __toCommonJS(index_exports);
@@ -7415,6 +7417,23 @@ function camelCase(input, options) {
74157417

74167418
// src/types.ts
74177419
var DELIMITER = "\r\n";
7420+
var JackdErrorCode = /* @__PURE__ */ ((JackdErrorCode2) => {
7421+
JackdErrorCode2["OUT_OF_MEMORY"] = "OUT_OF_MEMORY";
7422+
JackdErrorCode2["INTERNAL_ERROR"] = "INTERNAL_ERROR";
7423+
JackdErrorCode2["BAD_FORMAT"] = "BAD_FORMAT";
7424+
JackdErrorCode2["UNKNOWN_COMMAND"] = "UNKNOWN_COMMAND";
7425+
JackdErrorCode2["EXPECTED_CRLF"] = "EXPECTED_CRLF";
7426+
JackdErrorCode2["JOB_TOO_BIG"] = "JOB_TOO_BIG";
7427+
JackdErrorCode2["DRAINING"] = "DRAINING";
7428+
JackdErrorCode2["TIMED_OUT"] = "TIMED_OUT";
7429+
JackdErrorCode2["DEADLINE_SOON"] = "DEADLINE_SOON";
7430+
JackdErrorCode2["NOT_FOUND"] = "NOT_FOUND";
7431+
JackdErrorCode2["NOT_IGNORED"] = "NOT_IGNORED";
7432+
JackdErrorCode2["INVALID_RESPONSE"] = "INVALID_RESPONSE";
7433+
JackdErrorCode2["NOT_CONNECTED"] = "NOT_CONNECTED";
7434+
JackdErrorCode2["FATAL_CONNECTION_ERROR"] = "FATAL_CONNECTION_ERROR";
7435+
return JackdErrorCode2;
7436+
})(JackdErrorCode || {});
74187437
var JackdError = class extends Error {
74197438
/** Error code indicating the type of error */
74207439
code;
@@ -7495,7 +7514,7 @@ var JackdClient = class {
74957514
}
74967515
createSocket() {
74977516
this.socket = new import_net.Socket();
7498-
this.socket.setKeepAlive(true);
7517+
this.socket.setKeepAlive(true, 3e4);
74997518
this.socket.on("ready", () => {
75007519
this.connected = true;
75017520
void this.processNextCommand();
@@ -8273,5 +8292,7 @@ function findIndex(array, subarray) {
82738292
}
82748293
// Annotate the CommonJS export names for ESM import in node:
82758294
0 && (module.exports = {
8276-
JackdClient
8295+
JackdClient,
8296+
JackdError,
8297+
JackdErrorCode
82778298
});

dist/esm/index.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7409,6 +7409,23 @@ function camelCase(input, options) {
74097409

74107410
// src/types.ts
74117411
var DELIMITER = "\r\n";
7412+
var JackdErrorCode = /* @__PURE__ */ ((JackdErrorCode2) => {
7413+
JackdErrorCode2["OUT_OF_MEMORY"] = "OUT_OF_MEMORY";
7414+
JackdErrorCode2["INTERNAL_ERROR"] = "INTERNAL_ERROR";
7415+
JackdErrorCode2["BAD_FORMAT"] = "BAD_FORMAT";
7416+
JackdErrorCode2["UNKNOWN_COMMAND"] = "UNKNOWN_COMMAND";
7417+
JackdErrorCode2["EXPECTED_CRLF"] = "EXPECTED_CRLF";
7418+
JackdErrorCode2["JOB_TOO_BIG"] = "JOB_TOO_BIG";
7419+
JackdErrorCode2["DRAINING"] = "DRAINING";
7420+
JackdErrorCode2["TIMED_OUT"] = "TIMED_OUT";
7421+
JackdErrorCode2["DEADLINE_SOON"] = "DEADLINE_SOON";
7422+
JackdErrorCode2["NOT_FOUND"] = "NOT_FOUND";
7423+
JackdErrorCode2["NOT_IGNORED"] = "NOT_IGNORED";
7424+
JackdErrorCode2["INVALID_RESPONSE"] = "INVALID_RESPONSE";
7425+
JackdErrorCode2["NOT_CONNECTED"] = "NOT_CONNECTED";
7426+
JackdErrorCode2["FATAL_CONNECTION_ERROR"] = "FATAL_CONNECTION_ERROR";
7427+
return JackdErrorCode2;
7428+
})(JackdErrorCode || {});
74127429
var JackdError = class extends Error {
74137430
/** Error code indicating the type of error */
74147431
code;
@@ -7489,7 +7506,7 @@ var JackdClient = class {
74897506
}
74907507
createSocket() {
74917508
this.socket = new Socket();
7492-
this.socket.setKeepAlive(true);
7509+
this.socket.setKeepAlive(true, 3e4);
74937510
this.socket.on("ready", () => {
74947511
this.connected = true;
74957512
void this.processNextCommand();
@@ -8267,5 +8284,7 @@ function findIndex(array, subarray) {
82678284
}
82688285
export {
82698286
JackdClient,
8287+
JackdError,
8288+
JackdErrorCode,
82708289
index_default as default
82718290
};

dist/types/index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,3 +232,4 @@ export declare class JackdClient {
232232
listTubeUsed: () => Promise<string>;
233233
}
234234
export default JackdClient;
235+
export { JackdError, JackdErrorCode } from "./types";

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "jackd",
3-
"version": "4.0.5",
3+
"version": "4.0.7",
44
"description": "Modern beanstalkd client for Node.js",
55
"type": "module",
66
"exports": {

src/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ export class JackdClient {
115115

116116
private createSocket() {
117117
this.socket = new Socket()
118-
this.socket.setKeepAlive(true)
118+
this.socket.setKeepAlive(true, 30_000)
119119

120120
this.socket.on("ready", () => {
121121
this.connected = true
@@ -1012,3 +1012,5 @@ function findIndex(array: Uint8Array, subarray: Uint8Array): number {
10121012
}
10131013
return -1
10141014
}
1015+
1016+
export { JackdError, JackdErrorCode } from "./types"

0 commit comments

Comments
 (0)