bunqueue 2.8.6 → 2.8.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/application/operations/ack.d.ts +1 -1
- package/dist/application/operations/ack.js +2 -2
- package/dist/application/queueManager.d.ts +1 -1
- package/dist/application/queueManager.js +2 -2
- package/dist/application/statsManager.js +18 -8
- package/dist/cli/client.d.ts +3 -0
- package/dist/cli/client.js +13 -2
- package/dist/cli/commands/server.js +26 -2
- package/dist/cli/help.js +5 -0
- package/dist/cli/index.d.ts +5 -0
- package/dist/cli/index.js +53 -1
- package/dist/client/queue/dlq.js +1 -1
- package/dist/client/queue/operations/management.js +4 -2
- package/dist/client/queue/queue.js +2 -0
- package/dist/client/queue/scheduler.js +5 -0
- package/dist/client/tcp/client.js +1 -0
- package/dist/client/tcp/connection.d.ts +8 -1
- package/dist/client/tcp/connection.js +27 -1
- package/dist/client/tcp/index.d.ts +1 -1
- package/dist/client/tcp/shared.d.ts +6 -4
- package/dist/client/tcp/shared.js +27 -11
- package/dist/client/tcp/types.d.ts +13 -0
- package/dist/client/tcp/types.js +1 -0
- package/dist/client/tcpPool.js +11 -1
- package/dist/client/types.d.ts +8 -0
- package/dist/client/worker/worker.js +7 -2
- package/dist/client/worker/workerPull.d.ts +2 -0
- package/dist/client/worker/workerPull.js +12 -5
- package/dist/config/index.d.ts +1 -1
- package/dist/config/index.js +1 -1
- package/dist/config/resolve.d.ts +14 -0
- package/dist/config/resolve.js +19 -0
- package/dist/config/types.d.ts +4 -0
- package/dist/domain/types/command.d.ts +4 -0
- package/dist/infrastructure/server/handlers/advanced.js +60 -8
- package/dist/infrastructure/server/handlers/core.js +1 -1
- package/dist/infrastructure/server/handlers/cron.js +1 -0
- package/dist/infrastructure/server/handlers/monitoring.js +7 -2
- package/dist/infrastructure/server/http.d.ts +3 -0
- package/dist/infrastructure/server/http.js +30 -8
- package/dist/infrastructure/server/httpRouteJobs.js +14 -2
- package/dist/infrastructure/server/httpRouteQueueConfig.js +19 -3
- package/dist/infrastructure/server/httpRouteQueues.js +13 -1
- package/dist/infrastructure/server/httpRouteResources.js +4 -0
- package/dist/infrastructure/server/tcp.d.ts +6 -0
- package/dist/infrastructure/server/tcp.js +5 -1
- package/dist/infrastructure/server/tls.d.ts +21 -0
- package/dist/infrastructure/server/tls.js +19 -0
- package/dist/main.js +13 -1
- package/package.json +1 -1
|
@@ -11,6 +11,7 @@ import { getRateLimiter } from './rateLimiter';
|
|
|
11
11
|
import { pack, unpack } from 'msgpackr';
|
|
12
12
|
import { Semaphore, withSemaphore } from '../../shared/semaphore';
|
|
13
13
|
import { SocketWriteQueue } from './socketWriteQueue';
|
|
14
|
+
import { loadTlsOptions } from './tls';
|
|
14
15
|
/** Max concurrent commands per connection for pipelining */
|
|
15
16
|
const MAX_CONCURRENT_PER_CONNECTION = 50;
|
|
16
17
|
/**
|
|
@@ -236,10 +237,13 @@ export function createTcpServer(queueManager, config) {
|
|
|
236
237
|
socket.data.writeQueue.flush(socket);
|
|
237
238
|
},
|
|
238
239
|
};
|
|
239
|
-
// Create TCP server
|
|
240
|
+
// Create TCP server (validate TLS files BEFORE binding the port, so a bad
|
|
241
|
+
// path doesn't leave a half-started listener behind)
|
|
242
|
+
const tlsOptions = config.tls ? loadTlsOptions(config.tls) : undefined;
|
|
240
243
|
const server = Bun.listen({
|
|
241
244
|
hostname: config.hostname ?? '0.0.0.0',
|
|
242
245
|
port: config.port ?? 6789,
|
|
246
|
+
...(tlsOptions && { tls: tlsOptions }),
|
|
243
247
|
socket: socketHandlers,
|
|
244
248
|
});
|
|
245
249
|
return {
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Server TLS options
|
|
3
|
+
* Shared by the TCP (Bun.listen) and HTTP (Bun.serve) servers.
|
|
4
|
+
*/
|
|
5
|
+
import type { BunFile } from 'bun';
|
|
6
|
+
/** TLS configuration for a server (paths to PEM files) */
|
|
7
|
+
export interface TlsServerOptions {
|
|
8
|
+
/** Path to the PEM certificate (or full chain) file */
|
|
9
|
+
certFile: string;
|
|
10
|
+
/** Path to the PEM private key file */
|
|
11
|
+
keyFile: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Validate cert/key paths and build the `tls` option object for
|
|
15
|
+
* Bun.listen/Bun.serve. Fails fast with a descriptive error so a typo in a
|
|
16
|
+
* path surfaces at startup instead of as an opaque handshake failure.
|
|
17
|
+
*/
|
|
18
|
+
export declare function loadTlsOptions(tls: TlsServerOptions): {
|
|
19
|
+
cert: BunFile;
|
|
20
|
+
key: BunFile;
|
|
21
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Server TLS options
|
|
3
|
+
* Shared by the TCP (Bun.listen) and HTTP (Bun.serve) servers.
|
|
4
|
+
*/
|
|
5
|
+
import { existsSync } from 'node:fs';
|
|
6
|
+
/**
|
|
7
|
+
* Validate cert/key paths and build the `tls` option object for
|
|
8
|
+
* Bun.listen/Bun.serve. Fails fast with a descriptive error so a typo in a
|
|
9
|
+
* path surfaces at startup instead of as an opaque handshake failure.
|
|
10
|
+
*/
|
|
11
|
+
export function loadTlsOptions(tls) {
|
|
12
|
+
if (!existsSync(tls.certFile)) {
|
|
13
|
+
throw new Error(`TLS cert file not found: ${tls.certFile}`);
|
|
14
|
+
}
|
|
15
|
+
if (!existsSync(tls.keyFile)) {
|
|
16
|
+
throw new Error(`TLS key file not found: ${tls.keyFile}`);
|
|
17
|
+
}
|
|
18
|
+
return { cert: Bun.file(tls.certFile), key: Bun.file(tls.keyFile) };
|
|
19
|
+
}
|
package/dist/main.js
CHANGED
|
@@ -48,7 +48,7 @@ import { VERSION } from './shared/version';
|
|
|
48
48
|
import { S3BackupManager } from './infrastructure/backup';
|
|
49
49
|
import { CloudAgent } from './infrastructure/cloud';
|
|
50
50
|
import { SHARD_COUNT } from './shared/hash';
|
|
51
|
-
import { loadConfigFile, resolveServerConfig, resolveCloudConfig, resolveBackupConfig, } from './config';
|
|
51
|
+
import { loadConfigFile, resolveServerConfig, resolveCloudConfig, resolveBackupConfig, resolveTlsServerOptions, } from './config';
|
|
52
52
|
export { defineConfig } from './config';
|
|
53
53
|
/** Print startup banner */
|
|
54
54
|
function printBanner(config, cloudUrl) {
|
|
@@ -82,6 +82,7 @@ ${dim}────────────────────────
|
|
|
82
82
|
${green}●${reset} HTTP ${httpDisplay}
|
|
83
83
|
${yellow}●${reset} Socket ${socketDisplay}
|
|
84
84
|
${yellow}●${reset} Data ${config.dataPath ?? 'in-memory'}
|
|
85
|
+
${yellow}●${reset} TLS ${config.tlsCertFile ? `${green}enabled${reset}` : `${dim}disabled${reset}`}
|
|
85
86
|
${yellow}●${reset} Auth ${config.authTokens.length > 0 ? `${green}enabled${reset}` : `${dim}disabled${reset}`}
|
|
86
87
|
${yellow}●${reset} S3 Backup ${config.s3BackupEnabled ? `${green}enabled${reset}` : `${dim}disabled${reset}`}
|
|
87
88
|
${yellow}●${reset} Cloud ${cloudUrl ? `${green}enabled${reset} ${dim}→ ${cloudUrl}${reset}` : `${dim}disabled${reset}`}
|
|
@@ -108,6 +109,15 @@ async function startServer() {
|
|
|
108
109
|
}
|
|
109
110
|
// Resolve cloud config
|
|
110
111
|
const cloudConfig = resolveCloudConfig(fileConfig, config.dataPath);
|
|
112
|
+
// Resolve TLS config — fail fast on partial cert/key before binding anything
|
|
113
|
+
let tlsConfig;
|
|
114
|
+
try {
|
|
115
|
+
tlsConfig = resolveTlsServerOptions(config);
|
|
116
|
+
}
|
|
117
|
+
catch (err) {
|
|
118
|
+
serverLog.error(err instanceof Error ? err.message : String(err));
|
|
119
|
+
process.exit(1);
|
|
120
|
+
}
|
|
111
121
|
printBanner(config, cloudConfig?.url);
|
|
112
122
|
// Create queue manager
|
|
113
123
|
const queueManager = new QueueManager({
|
|
@@ -118,6 +128,7 @@ async function startServer() {
|
|
|
118
128
|
port: config.tcpPort,
|
|
119
129
|
hostname: config.hostname,
|
|
120
130
|
authTokens: config.authTokens,
|
|
131
|
+
...(tlsConfig && { tls: tlsConfig }),
|
|
121
132
|
});
|
|
122
133
|
// Start HTTP server
|
|
123
134
|
const httpServer = createHttpServer(queueManager, {
|
|
@@ -126,6 +137,7 @@ async function startServer() {
|
|
|
126
137
|
authTokens: config.authTokens,
|
|
127
138
|
corsOrigins: config.corsOrigins,
|
|
128
139
|
requireAuthForMetrics: config.requireAuthForMetrics,
|
|
140
|
+
...(tlsConfig && { tls: tlsConfig }),
|
|
129
141
|
});
|
|
130
142
|
// Initialize S3 backup manager
|
|
131
143
|
let backupManager = null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bunqueue",
|
|
3
|
-
"version": "2.8.
|
|
3
|
+
"version": "2.8.8",
|
|
4
4
|
"description": "High-performance job queue for Bun & AI agents. SQLite persistence, cron scheduling, priorities, retries, DLQ, webhooks, native MCP server. Zero external dependencies.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/main.js",
|