diff --git a/config/configUtils.js b/config/configUtils.js index c093c35ff..10bea5068 100644 --- a/config/configUtils.js +++ b/config/configUtils.js @@ -802,6 +802,12 @@ async function setConfiguration(setConfigJson) { } function readConfigFile() { + if (hdbUtils.noBootFile()) { + try { + const p = getConfigFilePath(null); + if (fs.existsSync(p)) return parseYamlDoc(p).toJSON(); + } catch (e) {} + } const bootPropsFilePath = hdbUtils.getPropsFilePath(); try { fs.accessSync(bootPropsFilePath, fs.constants.F_OK | fs.constants.R_OK); diff --git a/package-lock.json b/package-lock.json index 68fcf1151..7f81a172e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -345,6 +345,7 @@ "resolved": "https://registry.npmjs.org/@aws-sdk/client-s3/-/client-s3-3.1042.0.tgz", "integrity": "sha512-z3Ibstr7ckDT10dz/nkk4+93LitrrO49Oq563/JoFHt30ZNodPBCfSxysKcelLyi/lNVF1MZrhZZfikUAG3iNQ==", "license": "Apache-2.0", + "peer": true, "dependencies": { "@aws-crypto/sha1-browser": "5.2.0", "@aws-crypto/sha256-browser": "5.2.0", @@ -2252,6 +2253,7 @@ "version": "8.44.0", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@typescript-eslint/scope-manager": "8.44.0", "@typescript-eslint/types": "8.44.0", @@ -2972,8 +2974,7 @@ "optional": true, "os": [ "darwin" - ], - "peer": true + ] }, "node_modules/@msgpackr-extract/msgpackr-extract-darwin-x64": { "version": "3.0.3", @@ -2987,8 +2988,7 @@ "optional": true, "os": [ "darwin" - ], - "peer": true + ] }, "node_modules/@msgpackr-extract/msgpackr-extract-linux-arm": { "version": "3.0.3", @@ -3002,8 +3002,7 @@ "optional": true, "os": [ "linux" - ], - "peer": true + ] }, "node_modules/@msgpackr-extract/msgpackr-extract-linux-arm64": { "version": "3.0.3", @@ -3017,8 +3016,7 @@ "optional": true, "os": [ "linux" - ], - "peer": true + ] }, "node_modules/@msgpackr-extract/msgpackr-extract-linux-x64": { "version": "3.0.3", @@ -3030,8 +3028,7 @@ "optional": true, "os": [ "linux" - ], - "peer": true + ] }, "node_modules/@msgpackr-extract/msgpackr-extract-win32-x64": { "version": "3.0.3", @@ -3045,8 +3042,7 @@ "optional": true, "os": [ "win32" - ], - "peer": true + ] }, "node_modules/@noble/hashes": { "version": "1.8.0", @@ -3520,7 +3516,6 @@ "integrity": "sha512-GW2yqqOTzdz3K6z0XpPO1EjLzOw0kclmAcLeW6cBt0DYM7ZNLRKanpzXxaSXkePpo4ZYMWhddE4WpSWG8e/QaQ==", "dev": true, "license": "Apache-2.0", - "peer": true, "dependencies": { "@smithy/types": "^4.14.1", "tslib": "^2.6.2" @@ -4542,6 +4537,7 @@ "node_modules/@types/node": { "version": "25.4.0", "license": "MIT", + "peer": true, "dependencies": { "undici-types": "~7.18.0" } @@ -4636,6 +4632,7 @@ "integrity": "sha512-TI1XGwKbDpo9tRW8UDIXCOeLk55qe9ZFGs8MTKU6/M08HWTw52DD/IYhfQtOEhEdPhLMT26Ka/x7p70nd3dzDg==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@typescript-eslint/scope-manager": "8.59.0", "@typescript-eslint/types": "8.59.0", @@ -4856,6 +4853,7 @@ "version": "8.16.0", "dev": true, "license": "MIT", + "peer": true, "bin": { "acorn": "bin/acorn" }, @@ -5008,7 +5006,6 @@ "dev": true, "license": "MIT", "optional": true, - "peer": true, "engines": { "node": ">=0.10.0" } @@ -5020,7 +5017,6 @@ "dev": true, "license": "MIT", "optional": true, - "peer": true, "engines": { "node": ">=0.10.0" } @@ -5337,32 +5333,6 @@ "version": "1.1.2", "license": "MIT" }, - "node_modules/bufferutil": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/bufferutil/-/bufferutil-4.1.0.tgz", - "integrity": "sha512-ZMANVnAixE6AWWnPzlW2KpUrxhm9woycYvPOo67jWHyFowASTEd9s+QN1EIMsSDtwhIxN4sWE1jotpuDUIgyIw==", - "hasInstallScript": true, - "license": "MIT", - "optional": true, - "dependencies": { - "node-gyp-build": "^4.3.0" - }, - "engines": { - "node": ">=6.14.2" - } - }, - "node_modules/bufferutil/node_modules/node-gyp-build": { - "version": "4.8.4", - "resolved": "https://registry.npmjs.org/node-gyp-build/-/node-gyp-build-4.8.4.tgz", - "integrity": "sha512-LA4ZjwlnUblHVgq0oBF3Jl/6h/Nvs5fzBLwdEF4nuxnFdsfajde4WfxtJr3CaiH+F6ewcIB/q4jQ4UzPyid+CQ==", - "license": "MIT", - "optional": true, - "bin": { - "node-gyp-build": "bin.js", - "node-gyp-build-optional": "optional.js", - "node-gyp-build-test": "build-test.js" - } - }, "node_modules/bytestreamjs": { "version": "2.0.1", "license": "BSD-3-Clause", @@ -5461,6 +5431,7 @@ "version": "6.2.2", "dev": true, "license": "MIT", + "peer": true, "engines": { "node": ">=18" } @@ -5598,7 +5569,6 @@ "dev": true, "license": "MIT", "optional": true, - "peer": true, "dependencies": { "is-regexp": "^1.0.0", "is-supported-regexp-flag": "^1.0.0" @@ -6119,6 +6089,7 @@ "version": "9.39.4", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@eslint-community/eslint-utils": "^4.8.0", "@eslint-community/regexpp": "^4.12.1", @@ -6177,6 +6148,7 @@ "version": "10.1.8", "dev": true, "license": "MIT", + "peer": true, "bin": { "eslint-config-prettier": "bin/cli.js" }, @@ -6399,7 +6371,6 @@ "dev": true, "license": "MIT", "optional": true, - "peer": true, "dependencies": { "clone-regexp": "^1.0.0" }, @@ -7073,6 +7044,7 @@ "node_modules/graphql": { "version": "16.13.2", "license": "MIT", + "peer": true, "engines": { "node": "^12.22.0 || ^14.16.0 || ^16.0.0 || >=17.0.0" } @@ -7138,7 +7110,6 @@ "integrity": "sha512-RRXMLbbdymiZsHOeg5b+DShzsMvVvkgsG9690BBCc7tzIpDb0CT7EgWEQo+rwCICr35EwZoLjtfwF6mMiCOenA==", "dev": true, "license": "Apache-2.0", - "peer": true, "dependencies": { "@aws-sdk/client-s3": "^3.1012.0", "@aws-sdk/lib-storage": "3.964.0", @@ -7241,7 +7212,6 @@ "integrity": "sha512-ro6B04Q5TjPgIKdSWGJ+tj2ordVF1IfZJERwGpYkrwhboNEoXBXuzpfnh2LYBPvMmFJQ+8UXSFw1jkLLgxM+ig==", "dev": true, "license": "Apache-2.0", - "peer": true, "dependencies": { "@smithy/abort-controller": "^4.2.7", "@smithy/middleware-endpoint": "^4.4.1", @@ -7264,7 +7234,6 @@ "integrity": "sha512-gipd/g0USN8ncvRMdoaru8PxYNUSEJp//+XbLf+3VNDQ6gcSsTcYqyNa3f+oEKIyV0clpOkxzautkN7hVPsn/g==", "dev": true, "license": "Apache-2.0", - "peer": true, "dependencies": { "@harperfast/extended-iterable": "1.0.3", "msgpackr": "1.11.9", @@ -7297,7 +7266,6 @@ "os": [ "darwin" ], - "peer": true, "engines": { "node": ">=18" } @@ -7315,7 +7283,6 @@ "os": [ "darwin" ], - "peer": true, "engines": { "node": ">=18" } @@ -7333,7 +7300,6 @@ "os": [ "linux" ], - "peer": true, "engines": { "node": ">=18" } @@ -7351,7 +7317,6 @@ "os": [ "linux" ], - "peer": true, "engines": { "node": ">=18" } @@ -7369,7 +7334,6 @@ "os": [ "linux" ], - "peer": true, "engines": { "node": ">=18" } @@ -7387,7 +7351,6 @@ "os": [ "linux" ], - "peer": true, "engines": { "node": ">=18" } @@ -7405,7 +7368,6 @@ "os": [ "win32" ], - "peer": true, "engines": { "node": ">=18" } @@ -7423,7 +7385,6 @@ "os": [ "win32" ], - "peer": true, "engines": { "node": ">=18" } @@ -7440,8 +7401,7 @@ "optional": true, "os": [ "darwin" - ], - "peer": true + ] }, "node_modules/harper/node_modules/@lmdb/lmdb-darwin-x64": { "version": "3.5.3", @@ -7455,8 +7415,7 @@ "optional": true, "os": [ "darwin" - ], - "peer": true + ] }, "node_modules/harper/node_modules/@lmdb/lmdb-linux-arm": { "version": "3.5.3", @@ -7470,8 +7429,7 @@ "optional": true, "os": [ "linux" - ], - "peer": true + ] }, "node_modules/harper/node_modules/@lmdb/lmdb-linux-arm64": { "version": "3.5.3", @@ -7485,8 +7443,7 @@ "optional": true, "os": [ "linux" - ], - "peer": true + ] }, "node_modules/harper/node_modules/@lmdb/lmdb-linux-x64": { "version": "3.5.3", @@ -7500,8 +7457,7 @@ "optional": true, "os": [ "linux" - ], - "peer": true + ] }, "node_modules/harper/node_modules/@lmdb/lmdb-win32-arm64": { "version": "3.5.3", @@ -7515,8 +7471,7 @@ "optional": true, "os": [ "win32" - ], - "peer": true + ] }, "node_modules/harper/node_modules/@lmdb/lmdb-win32-x64": { "version": "3.5.3", @@ -7530,8 +7485,7 @@ "optional": true, "os": [ "win32" - ], - "peer": true + ] }, "node_modules/harper/node_modules/asn1js": { "version": "3.0.7", @@ -7539,7 +7493,6 @@ "integrity": "sha512-uLvq6KJu04qoQM6gvBfKFjlh6Gl0vOKQuR5cJMDHQkmwfMOQeN3F3SHCv9SNYSL+CRoHvOGFfllDlVz03GQjvQ==", "dev": true, "license": "BSD-3-Clause", - "peer": true, "dependencies": { "pvtsutils": "^1.3.6", "pvutils": "^1.1.3", @@ -7555,7 +7508,6 @@ "integrity": "sha512-VWSRii4t0AFm6ixFFmLLx1t7wS1gh+ckoa84aOeapGum0h+EZd1EhEumSB+ZdDLnEPuucsVB9oB7cxJHap6Afg==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "graceful-fs": "^4.2.0", "jsonfile": "^6.0.1", @@ -7571,7 +7523,6 @@ "integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "safer-buffer": ">= 2.1.2 < 3.0.0" }, @@ -7586,7 +7537,6 @@ "dev": true, "hasInstallScript": true, "license": "MIT", - "peer": true, "dependencies": { "@harperfast/extended-iterable": "^1.0.3", "msgpackr": "^1.11.2", @@ -7614,7 +7564,6 @@ "integrity": "sha512-FkoAAyyA6HM8wL882EcEyFZ9s7hVADSwG9xrVx3dxxNQAtgADTrJoEWivID82Iv1zWDsv/OtbrrcZAzGzOMdNw==", "dev": true, "license": "MIT", - "peer": true, "optionalDependencies": { "msgpackr-extract": "^3.0.2" } @@ -7625,7 +7574,6 @@ "integrity": "sha512-6k0YULvhpw+RoLNiQCRKOl09Rv1dPLr8hHnVjHqdolKwDrdNyk+Hmrthi4lIGPPz3r39dLx0hsF5s40sZ3Us4Q==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "iconv-lite": "^0.6.3", "sax": "^1.2.4" @@ -7642,8 +7590,7 @@ "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-6.1.0.tgz", "integrity": "sha512-+eawOlIgy680F0kBzPUNFhMZGtJ1YmqM6l4+Crf4IkImjYrO/mqPwRMh352g23uIaQKFItcQ64I7KMaJxHgAVA==", "dev": true, - "license": "MIT", - "peer": true + "license": "MIT" }, "node_modules/harper/node_modules/node-gyp-build-optional-packages": { "version": "5.2.2", @@ -7651,7 +7598,6 @@ "integrity": "sha512-s+w+rBWnpTMwSFbaE0UXsRlg7hU4FjekKU4eyAih5T8nJuNZT1nNsskXpxmeqSK9UzkBl6UgRlnKc8hz8IEqOw==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "detect-libc": "^2.0.1" }, @@ -7667,7 +7613,6 @@ "integrity": "sha512-UUmvQ/7KTZt/vHjhRrnyS7h+J7qPBQnpG80V56xmIC+o9IqYmQOw/UIny9S9zYDfRBR0ClouCr464EkBMIT7Fw==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "atomic-sleep": "^1.0.0", "fast-redact": "^3.1.1", @@ -7691,7 +7636,6 @@ "integrity": "sha512-lsleG3/2a/JIWUtf9Q5gUNErBqwIu1tUKTT3dUzaf5DySw9ra1wcqKjJjLX1VTY64Wk1eEOYsVGSaGfCK85ekA==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "readable-stream": "^4.0.0", "split2": "^4.0.0" @@ -7703,7 +7647,6 @@ "integrity": "sha512-WX0la7n7CbnguuaIQoT4Fc0IJckPDOUldzOwlZ0nwpOcySS+Six/tXBdc0RX17J5o1To0SAr3xDJjDLsOfDFQA==", "dev": true, "license": "BSD-3-Clause", - "peer": true, "dependencies": { "@noble/hashes": "^1.4.0", "asn1js": "^3.0.5", @@ -7721,8 +7664,7 @@ "resolved": "https://registry.npmjs.org/process-warning/-/process-warning-2.3.2.tgz", "integrity": "sha512-n9wh8tvBe5sFmsqlg+XQhaQLumwpqoAUruLwjCopgTmUBjJ/fjtBsJzKleCaIGBOMXYEhp1YfKl4d7rJ5ZKJGA==", "dev": true, - "license": "MIT", - "peer": true + "license": "MIT" }, "node_modules/harper/node_modules/readable-stream": { "version": "4.7.0", @@ -7730,7 +7672,6 @@ "integrity": "sha512-oIGGmcpTLwPga8Bn6/Z75SVaH1z5dUut2ibSyAMVhmUggWpmDn2dapB0n7f8nwaSiRtepAsfJyfXIO5DCVAODg==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "abort-controller": "^3.0.0", "buffer": "^6.0.3", @@ -7762,7 +7703,6 @@ } ], "license": "MIT", - "peer": true, "dependencies": { "base64-js": "^1.3.1", "ieee754": "^1.2.1" @@ -7774,7 +7714,6 @@ "integrity": "sha512-SdsKMrI9TdgjdweUSR9MweHA4EJ8YxHn8DFaDisvhVlUOe4BF1tLD7GAj0lIqWVl+dPb/rExr0Btby5loQm20Q==", "dev": true, "license": "ISC", - "peer": true, "bin": { "semver": "bin/semver.js" }, @@ -7788,7 +7727,6 @@ "integrity": "sha512-UcjcJOWknrNkF6PLX83qcHM6KHgVKNkV62Y8a5uYDVv9ydGQVwAHMKqHdJje1VTWpljG0WYpCDhrCdAOYH4TWg==", "dev": true, "license": "ISC", - "peer": true, "engines": { "node": ">= 10.x" } @@ -7799,7 +7737,6 @@ "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "safe-buffer": "~5.2.0" } @@ -7810,7 +7747,6 @@ "integrity": "sha512-PEIGCY5tSlUt50cqyMXfCzX+oOPqN0vuGqWzbcJ2xvnkzkq46oOpz7dQaTDBdfICb4N14+GARUDw2XV2N4tvzg==", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=10.0.0" }, @@ -7833,7 +7769,6 @@ "integrity": "sha512-mplynKqc1C2hTVYxd0PU2xQAc22TI1vShAYGksCCfxbn/dFwnHTNi1bvYsBTkhdUNtGIf5xNOg938rrSSYvS9A==", "dev": true, "license": "ISC", - "peer": true, "bin": { "yaml": "bin.mjs" }, @@ -7901,7 +7836,6 @@ "dev": true, "license": "MIT", "optional": true, - "peer": true, "dependencies": { "parse-columns": "git+https://github.com/int0h/parse-columns.git" } @@ -8157,7 +8091,6 @@ "dev": true, "license": "MIT", "optional": true, - "peer": true, "engines": { "node": ">=0.10.0" }, @@ -8245,7 +8178,6 @@ "dev": true, "license": "MIT", "optional": true, - "peer": true, "engines": { "node": ">=0.10.0" } @@ -8257,7 +8189,6 @@ "dev": true, "license": "MIT", "optional": true, - "peer": true, "engines": { "node": ">=0.10.0" } @@ -9338,7 +9269,6 @@ "dev": true, "license": "MIT", "optional": true, - "peer": true, "dependencies": { "number-is-nan": "^1.0.0" }, @@ -9362,7 +9292,6 @@ "dev": true, "license": "MIT", "optional": true, - "peer": true, "engines": { "node": ">=0.10.0" } @@ -9706,7 +9635,6 @@ "dev": true, "license": "MIT", "optional": true, - "peer": true, "dependencies": { "escape-string-regexp": "^1.0.3", "execall": "^1.0.0", @@ -9724,7 +9652,6 @@ "dev": true, "license": "MIT", "optional": true, - "peer": true, "engines": { "node": ">=0.8.0" } @@ -10002,6 +9929,7 @@ "integrity": "sha512-7igPTM53cGHMW8xWuVTydi2KO233VFiTNyF5hLJqpilHfmn8C8gPf+PS7dUT64YcXFbiMGZxS9pCSxL/Dxm/Jw==", "dev": true, "license": "MIT", + "peer": true, "bin": { "prettier": "bin/prettier.cjs" }, @@ -10262,7 +10190,6 @@ "dev": true, "license": "MIT", "optional": true, - "peer": true, "dependencies": { "is-finite": "^1.0.0" }, @@ -10757,7 +10684,6 @@ "dev": true, "license": "MIT", "optional": true, - "peer": true, "dependencies": { "array-uniq": "^1.0.2", "arrify": "^1.0.0", @@ -11117,6 +11043,7 @@ "integrity": "sha512-QP88BAKvMam/3NxH6vj2o21R6MjxZUAd6nlwAS/pnGvN9IVLocLHxGYIzFhg6fUQ+5th6P4dv4eW9jX3DSIj7A==", "dev": true, "license": "MIT", + "peer": true, "engines": { "node": ">=12" }, @@ -11230,6 +11157,7 @@ "version": "5.9.3", "dev": true, "license": "Apache-2.0", + "peer": true, "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" @@ -11298,32 +11226,6 @@ "punycode": "^2.1.0" } }, - "node_modules/utf-8-validate": { - "version": "5.0.10", - "resolved": "https://registry.npmjs.org/utf-8-validate/-/utf-8-validate-5.0.10.tgz", - "integrity": "sha512-Z6czzLq4u8fPOyx7TU6X3dvUZVvoJmxSQ+IcrlmagKhilxlhZgxPK6C5Jqbkw1IDUmFTM+cz9QDnnLTwDz/2gQ==", - "hasInstallScript": true, - "license": "MIT", - "optional": true, - "dependencies": { - "node-gyp-build": "^4.3.0" - }, - "engines": { - "node": ">=6.14.2" - } - }, - "node_modules/utf-8-validate/node_modules/node-gyp-build": { - "version": "4.8.4", - "resolved": "https://registry.npmjs.org/node-gyp-build/-/node-gyp-build-4.8.4.tgz", - "integrity": "sha512-LA4ZjwlnUblHVgq0oBF3Jl/6h/Nvs5fzBLwdEF4nuxnFdsfajde4WfxtJr3CaiH+F6ewcIB/q4jQ4UzPyid+CQ==", - "license": "MIT", - "optional": true, - "bin": { - "node-gyp-build": "bin.js", - "node-gyp-build-optional": "optional.js", - "node-gyp-build-test": "build-test.js" - } - }, "node_modules/util-deprecate": { "version": "1.0.2", "license": "MIT" diff --git a/server/DurableSubscriptionsSession.ts b/server/DurableSubscriptionsSession.ts index 9545c601e..5488bc10a 100644 --- a/server/DurableSubscriptionsSession.ts +++ b/server/DurableSubscriptionsSession.ts @@ -10,37 +10,53 @@ import { RequestTarget } from '../resources/RequestTarget'; import { cloneDeep } from 'lodash'; const AWAITING_ACKS_HIGH_WATER_MARK = 100; -const DurableSession = table({ - database: 'system', - table: 'hdb_durable_session', - attributes: [ - { name: 'id', isPrimaryKey: true }, - { - name: 'subscriptions', - type: 'array', - elements: { - attributes: [{ name: 'topic' }, { name: 'qos' }, { name: 'startTime' }, { name: 'acks' }], - }, - }, - ], -}); -const LastWill = table({ - database: 'system', - table: 'hdb_session_will', - attributes: [ - { name: 'id', isPrimaryKey: true }, - { name: 'topic', type: 'string' }, - { name: 'data' }, - { name: 'qos', type: 'number' }, - { name: 'retain', type: 'boolean' }, - { name: 'user', type: 'any' }, - ], -}); +let _DurableSession: any; +function getDurableSession() { + if (!_DurableSession) { + _DurableSession = table({ + database: 'system', + table: 'hdb_durable_session', + attributes: [ + { name: 'id', isPrimaryKey: true }, + { + name: 'subscriptions', + type: 'array', + elements: { + attributes: [{ name: 'topic' }, { name: 'qos' }, { name: 'startTime' }, { name: 'acks' }], + }, + }, + { + name: 'awaitingAcks', + type: 'array', + }, + ], + }); + } + return _DurableSession; +} +let _LastWill: any; +function getLastWill() { + if (!_LastWill) { + _LastWill = table({ + database: 'system', + table: 'hdb_session_will', + attributes: [ + { name: 'id', isPrimaryKey: true }, + { name: 'topic', type: 'string' }, + { name: 'data' }, + { name: 'qos', type: 'number' }, + { name: 'retain', type: 'boolean' }, + { name: 'user', type: 'any' }, + ], + }); + } + return _LastWill; +} if (getWorkerIndex() === 0) { (async () => { await whenComponentsLoaded; await new Promise((resolve) => setTimeout(resolve, 2000)); - for await (const will of LastWill.search({})) { + for await (const will of getLastWill().search({})) { const data = will.data; const message = { ...will }; if (message.user?.username) message.user = await server.getUser(message.user.username); @@ -49,7 +65,7 @@ if (getWorkerIndex() === 0) { } catch { warn('Failed to publish will', data); } - LastWill.delete(will.id); + getLastWill().delete(will.id); } })(); } @@ -99,21 +115,21 @@ export async function getSession({ let session; if (properties?.sessionExpiryInterval > 0) nonDurable = false; if (sessionId && !nonDurable) { - const sessionResource = await DurableSession.get(sessionId, { returnNonexistent: true }); + const sessionResource = await getDurableSession().get(sessionId, { returnNonexistent: true }); session = new DurableSubscriptionsSession(sessionId, user, sessionResource); if (sessionResource) session.sessionWasPresent = true; } else { if (sessionId) { // connecting with a clean session and session id is how durable sessions are deleted - const sessionResource = await DurableSession.get(sessionId); - if (sessionResource) DurableSession.delete(sessionId); + const sessionResource = await getDurableSession().get(sessionId); + if (sessionResource) getDurableSession().delete(sessionId); } session = new SubscriptionsSession(sessionId, user); } if (will) { will.id = sessionId; will.user = { username: user?.username }; - LastWill.put(will); + getLastWill().put(will); } if (keepalive) { // keep alive is the interval in seconds that the client will send a ping to the server @@ -361,13 +377,13 @@ class SubscriptionsSession { transaction(context, async () => { try { if (!clientTerminated) { - const will = await LastWill.get(this.sessionId); + const will = await getLastWill().get(this.sessionId); if (will) { await publish(will, will.data, context); } } } finally { - await LastWill.delete(this.sessionId); + await getLastWill().delete(this.sessionId); } }).catch((error) => { warn(`Error publishing MQTT will for ${this.sessionId}`, error); @@ -462,7 +478,7 @@ export class DurableSubscriptionsSession extends SubscriptionsSession { } subscription.acks.push(update.timestamp); trace('Received ack', topic, update.timestamp); - DurableSession.put(this.sessionRecord, { source: true }); // add source: true context to bypass any overloaded checks, as skipping this can lead to increased load + getDurableSession().put(this.sessionRecord, { source: true }); // add source: true context to bypass any overloaded checks, as skipping this can lead to increased load return; } } @@ -475,7 +491,7 @@ export class DurableSubscriptionsSession extends SubscriptionsSession { subscription.startTime = update.timestamp; } } - DurableSession.put(this.sessionRecord, { source: true }); + getDurableSession().put(this.sessionRecord, { source: true }); // TODO: Increment the timestamp for the corresponding subscription, possibly recording any interim unacked messages } @@ -502,6 +518,6 @@ export class DurableSubscriptionsSession extends SubscriptionsSession { startTime, }; }); - return DurableSession.put(this.sessionRecord); + return getDurableSession().put(this.sessionRecord); } } diff --git a/server/serverHelpers/Request.ts b/server/serverHelpers/Request.ts index 7c746490a..aebcd5331 100644 --- a/server/serverHelpers/Request.ts +++ b/server/serverHelpers/Request.ts @@ -206,7 +206,7 @@ export class Request { return capturedHeaders.get(name); }, getHeaders() { - return Object.fromEntries(capturedHeaders); + return Object.fromEntries(capturedHeaders.entries()); }, hasHeader(name: string) { return capturedHeaders.has(name); diff --git a/unitTests/security/keys.test.js b/unitTests/security/keys.test.js index ebaae0496..64547df92 100644 --- a/unitTests/security/keys.test.js +++ b/unitTests/security/keys.test.js @@ -71,10 +71,13 @@ describe('Test keys module', () => { }); }); - afterEach(async () => { + after(async () => { sandbox.restore(); await fs.remove(test_dir); }); + afterEach(() => { + sandbox.restore(); + }); it('Test loadCertificates loads certs from config file', async () => { // Load loadCertificates is called in the before method because other tests rely on it