diff --git a/Library/Sender.ts b/Library/Sender.ts index 0ffae029..d32db574 100644 --- a/Library/Sender.ts +++ b/Library/Sender.ts @@ -48,7 +48,6 @@ class Sender { private _fileCleanupTimer: NodeJS.Timer; private _redirectedHost: string = null; private _tempDir: string; - private _processId: number = process.pid; private _requestTimedOut: boolean; protected _resendInterval: number; protected _maxBytesOnDisk: number; @@ -429,7 +428,7 @@ class Sender { try { //create file - file name for now is the timestamp, a better approach would be a UUID but that //would require an external dependency - var fileName = `${new Date().getTime()}.${this._processId}.ai.json`; + var fileName = `${new Date().getTime()}.ai.json`; var fileFullPath = path.join(this._tempDir, fileName); // Mode 600 is w/r for creator and no read access for others (only applies on *nix) @@ -466,7 +465,7 @@ class Sender { //create file - file name for now is the timestamp, a better approach would be a UUID but that //would require an external dependency - var fileName = `${new Date().getTime()}.${this._processId}.ai.json`; + var fileName = `${new Date().getTime()}.ai.json`; var fileFullPath = path.join(this._tempDir, fileName); // Mode 600 is w/r for creator and no access for anyone else (only applies on *nix) @@ -486,7 +485,7 @@ class Sender { private async _sendFirstFileOnDisk(): Promise { try { let files = await FileSystemHelper.readdirAsync(this._tempDir); - files = files.filter(f => path.basename(f).indexOf(`${process.pid}.ai.json`) > -1); + files = files.filter(f => path.basename(f).indexOf(".ai.json") > -1); if (files.length > 0) { var firstFile = files[0]; var filePath = path.join(this._tempDir, firstFile); @@ -511,11 +510,11 @@ class Sender { private async _fileCleanupTask(): Promise { try { let files = await FileSystemHelper.readdirAsync(this._tempDir); - files = files.filter(f => path.basename(f).indexOf(`${this._processId}.ai.json`) > -1); + files = files.filter(f => path.basename(f).indexOf(".ai.json") > -1); if (files.length > 0) { for (let i = 0; i < files.length; i++) { // Check expiration - let fileCreationDate: Date = new Date(parseInt(files[i].split(`${this._processId}.ai.json`)[0])); + let fileCreationDate: Date = new Date(parseInt(files[i].split(".ai.json")[0])); let expired = new Date(+(new Date()) - Sender.FILE_RETEMPTION_PERIOD) > fileCreationDate; if (expired) { var filePath = path.join(this._tempDir, files[i]); diff --git a/Tests/EndToEnd.tests.ts b/Tests/EndToEnd.tests.ts index 383c4566..a51b6571 100644 --- a/Tests/EndToEnd.tests.ts +++ b/Tests/EndToEnd.tests.ts @@ -483,8 +483,8 @@ describe("EndToEnd", () => { writeFile = sandbox.stub(FileSystemHelper, 'writeFileAsync'); writeFileSync = sandbox.stub(fs, 'writeFileSync'); existsSync = sandbox.stub(fs, 'existsSync').returns(true); - readdir = sandbox.stub(FileSystemHelper, 'readdirAsync').returns([`${process.pid}.ai.json`]); - readdirSync = sandbox.stub(fs, 'readdirSync').returns([`${process.pid}.ai.json`]); + readdir = sandbox.stub(FileSystemHelper, 'readdirAsync').returns(['1.ai.json']); + readdirSync = sandbox.stub(fs, 'readdirSync').returns(['.ai.json']); stat = sandbox.stub(FileSystemHelper, 'statAsync').returns({ isFile: () => true, size: 8000 }); statSync = sandbox.stub(fs, 'statSync').returns({ isFile: () => true, size: 8000 }); lstat = sandbox.stub(FileSystemHelper, 'lstatAsync').returns({ isDirectory: () => true }); diff --git a/package-lock.json b/package-lock.json index 237f9c45..c3e99d6e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -61,27 +61,27 @@ } }, "node_modules/@azure/abort-controller": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/@azure/abort-controller/-/abort-controller-1.1.0.tgz", - "integrity": "sha512-TrRLIoSQVzfAJX9H1JeFjzAoDGcoK1IYX1UImfceTZpsyYfWr09Ss1aHW1y5TrrR3iq6RZLBwJ3E24uwPhwahw==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@azure/abort-controller/-/abort-controller-2.0.0.tgz", + "integrity": "sha512-RP/mR/WJchR+g+nQFJGOec+nzeN/VvjlwbinccoqfhTsTHbb8X5+mLDp48kHT0ueyum0BNSwGm0kX0UZuIqTGg==", "dependencies": { "tslib": "^2.2.0" }, "engines": { - "node": ">=12.0.0" + "node": ">=18.0.0" } }, "node_modules/@azure/core-auth": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/@azure/core-auth/-/core-auth-1.5.0.tgz", - "integrity": "sha512-udzoBuYG1VBoHVohDTrvKjyzel34zt77Bhp7dQntVGGD0ehVq48owENbBG8fIgkHRNUBQH5k1r0hpoMu5L8+kw==", + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/@azure/core-auth/-/core-auth-1.6.0.tgz", + "integrity": "sha512-3X9wzaaGgRaBCwhLQZDtFp5uLIXCPrGbwJNWPPugvL4xbIGgScv77YzzxToKGLAKvG9amDoofMoP+9hsH1vs1w==", "dependencies": { - "@azure/abort-controller": "^1.0.0", + "@azure/abort-controller": "^2.0.0", "@azure/core-util": "^1.1.0", "tslib": "^2.2.0" }, "engines": { - "node": ">=14.0.0" + "node": ">=18.0.0" } }, "node_modules/@azure/core-rest-pipeline": { @@ -104,6 +104,17 @@ "node": ">=14.0.0" } }, + "node_modules/@azure/core-rest-pipeline/node_modules/@azure/abort-controller": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@azure/abort-controller/-/abort-controller-1.1.0.tgz", + "integrity": "sha512-TrRLIoSQVzfAJX9H1JeFjzAoDGcoK1IYX1UImfceTZpsyYfWr09Ss1aHW1y5TrrR3iq6RZLBwJ3E24uwPhwahw==", + "dependencies": { + "tslib": "^2.2.0" + }, + "engines": { + "node": ">=12.0.0" + } + }, "node_modules/@azure/core-tracing": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/@azure/core-tracing/-/core-tracing-1.0.1.tgz", @@ -127,6 +138,17 @@ "node": ">=14.0.0" } }, + "node_modules/@azure/core-util/node_modules/@azure/abort-controller": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@azure/abort-controller/-/abort-controller-1.1.0.tgz", + "integrity": "sha512-TrRLIoSQVzfAJX9H1JeFjzAoDGcoK1IYX1UImfceTZpsyYfWr09Ss1aHW1y5TrrR3iq6RZLBwJ3E24uwPhwahw==", + "dependencies": { + "tslib": "^2.2.0" + }, + "engines": { + "node": ">=12.0.0" + } + }, "node_modules/@azure/functions": { "version": "3.5.1", "resolved": "https://registry.npmjs.org/@azure/functions/-/functions-3.5.1.tgz", @@ -629,9 +651,9 @@ "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==" }, "node_modules/available-typed-arrays": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/available-typed-arrays/-/available-typed-arrays-1.0.5.tgz", - "integrity": "sha512-DMD0KiN46eipeziST1LPP/STfDU0sufISXmjSgvVsoU2tqxctQeASejWcfNtxYKqETM1UxQ8sp2OrSBWpHY6sw==", + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/available-typed-arrays/-/available-typed-arrays-1.0.6.tgz", + "integrity": "sha512-j1QzY8iPNPG4o4xmO3ptzpRxTciqD3MgEHtifP/YnJpIo58Xu+ne4BejlbkuaLfXn/nz6HFiw29bLpj2PNMdGg==", "dev": true, "engines": { "node": ">= 0.4" @@ -1584,12 +1606,12 @@ } }, "node_modules/has-tostringtag": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/has-tostringtag/-/has-tostringtag-1.0.0.tgz", - "integrity": "sha512-kFjcSNhnlGV1kyoGk7OXKSawH5JOb/LzUc5w9B02hOTO0dfFRjbHQKvg1d6cf3HbeUmtU9VbbV3qzZ2Teh97WQ==", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/has-tostringtag/-/has-tostringtag-1.0.2.tgz", + "integrity": "sha512-NqADB8VjPFLM2V0VvHUewwwsw0ZWBaIdgo+ieHtK3hasLz4qeCRjYcqfB6AQrBggRKppKF8L52/VqdVsO47Dlw==", "dev": true, "dependencies": { - "has-symbols": "^1.0.2" + "has-symbols": "^1.0.3" }, "engines": { "node": ">= 0.4" @@ -1662,9 +1684,9 @@ } }, "node_modules/ignore": { - "version": "5.3.0", - "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.0.tgz", - "integrity": "sha512-g7dmpshy+gD7mh88OC9NwSGTKoc3kyLAZQRU1mt53Aw/vnvfXnbC+F/7F7QoYVKbV+KNvJx8wArewKy1vXMtlg==", + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.1.tgz", + "integrity": "sha512-5Fytz/IraMjqpwfd34ke28PTVMjZjJG2MPn5t7OE4eUCUNf8BAa7b5WUS9/Qvr6mwOQS7Mk6vdsMno5he+T8Xw==", "dev": true, "engines": { "node": ">= 4" @@ -1846,12 +1868,12 @@ } }, "node_modules/is-typed-array": { - "version": "1.1.12", - "resolved": "https://registry.npmjs.org/is-typed-array/-/is-typed-array-1.1.12.tgz", - "integrity": "sha512-Z14TF2JNG8Lss5/HMqt0//T9JeHXttXy5pH/DBU4vi98ozO2btxzq9MwYDZYnKwU8nRsz/+GVFVRDq3DkVuSPg==", + "version": "1.1.13", + "resolved": "https://registry.npmjs.org/is-typed-array/-/is-typed-array-1.1.13.tgz", + "integrity": "sha512-uZ25/bUAlUY5fR4OKT4rZQEBrzQWYV9ZJYGGsUmEJ6thodVJ1HX64ePQ6Z0qPWP+m+Uq6e9UugrE38jeYsDSMw==", "dev": true, "dependencies": { - "which-typed-array": "^1.1.11" + "which-typed-array": "^1.1.14" }, "engines": { "node": ">= 0.4" @@ -2983,16 +3005,16 @@ } }, "node_modules/which-typed-array": { - "version": "1.1.13", - "resolved": "https://registry.npmjs.org/which-typed-array/-/which-typed-array-1.1.13.tgz", - "integrity": "sha512-P5Nra0qjSncduVPEAr7xhoF5guty49ArDTwzJ/yNuPIbZppyRxFQsRCWrocxIY+CnMVG+qfbU2FmDKyvSGClow==", + "version": "1.1.14", + "resolved": "https://registry.npmjs.org/which-typed-array/-/which-typed-array-1.1.14.tgz", + "integrity": "sha512-VnXFiIW8yNn9kIHN88xvZ4yOWchftKDsRJ8fEPacX/wl1lOvBrhsJ/OeJCXq7B0AaijRuqgzSKalJoPk+D8MPg==", "dev": true, "dependencies": { - "available-typed-arrays": "^1.0.5", - "call-bind": "^1.0.4", + "available-typed-arrays": "^1.0.6", + "call-bind": "^1.0.5", "for-each": "^0.3.3", "gopd": "^1.0.1", - "has-tostringtag": "^1.0.0" + "has-tostringtag": "^1.0.1" }, "engines": { "node": ">= 0.4"