Skip to content

Commit 05f51fb

Browse files
build - 1.4.1
1 parent b9a9ce4 commit 05f51fb

File tree

6 files changed

+27
-12
lines changed

6 files changed

+27
-12
lines changed

dist/src/index.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,12 @@ const Logger_1 = __importDefault(require("./libraries/Logger"));
3131
const os = __importStar(require("node:os"));
3232
const Executor_1 = __importDefault(require("./libraries/Executor"));
3333
const semver_1 = require("semver");
34-
const AbortSignal_1 = __importDefault(require("./libraries/AbortSignal"));
3534
const Version_1 = __importDefault(require("./libraries/Version"));
3635
const versions_json_1 = __importDefault(require("./versions.json"));
3736
const Downloader_1 = require("./libraries/Downloader");
3837
const crypto_1 = require("crypto");
3938
const path_1 = require("path");
4039
const constants_1 = __importDefault(require("./constants"));
41-
process.on('exit', () => {
42-
AbortSignal_1.default.abort('Process is exiting');
43-
});
4440
async function createDB(opts) {
4541
const defaultOptions = {
4642
dbName: 'dbdata',

dist/src/libraries/AbortSignal.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
"use strict";
22
Object.defineProperty(exports, "__esModule", { value: true });
33
const DBDestroySignal = new AbortController();
4+
function abortSignal() {
5+
if (!DBDestroySignal.signal.aborted) {
6+
DBDestroySignal.abort('Process is exiting');
7+
}
8+
}
9+
process.on('beforeExit', abortSignal);
10+
process.on('exit', abortSignal);
411
exports.default = DBDestroySignal;

dist/src/libraries/Downloader.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ function downloadFromCDN(url, downloadLocation, logger) {
107107
});
108108
});
109109
}
110-
function extractBinary(url, archiveLocation, extractedLocation) {
110+
function extractBinary(url, archiveLocation, extractedLocation, logger) {
111111
return new Promise(async (resolve, reject) => {
112112
const lastDashIndex = url.lastIndexOf('-');
113113
const fileExtension = url.slice(lastDashIndex).split('.').splice(1).join('.');
@@ -140,17 +140,23 @@ function extractBinary(url, archiveLocation, extractedLocation) {
140140
try {
141141
await fsPromises.rm(archiveLocation);
142142
}
143+
catch (e) {
144+
logger.error('A non-fatal error occurred while removing no longer needed archive file:', e);
145+
}
143146
finally {
144-
fsPromises.rename(`${extractedLocation}/${folderName}`, `${extractedLocation}/mysql`);
147+
await fsPromises.rename(`${extractedLocation}/${folderName}`, `${extractedLocation}/mysql`);
145148
return resolve((0, path_1.normalize)(`${extractedLocation}/mysql/bin/mysqld.exe`));
146149
}
147150
}
148151
handleTarExtraction(archiveLocation, extractedLocation).then(async () => {
149152
try {
150153
await fsPromises.rm(archiveLocation);
151154
}
155+
catch (e) {
156+
logger.error('A non-fatal error occurred while removing no longer needed archive file:', e);
157+
}
152158
finally {
153-
fsPromises.rename(`${extractedLocation}/${folderName}`, `${extractedLocation}/mysql`);
159+
await fsPromises.rename(`${extractedLocation}/${folderName}`, `${extractedLocation}/mysql`);
154160
resolve(`${extractedLocation}/mysql/bin/mysqld`);
155161
}
156162
}).catch(error => {
@@ -180,7 +186,7 @@ function downloadBinary(binaryInfo, options, logger) {
180186
(0, proper_lockfile_1.lockSync)(extractedPath);
181187
lockedByUs = true;
182188
await downloadFromCDN(url, archivePath, logger);
183-
await extractBinary(url, archivePath, extractedPath);
189+
await extractBinary(url, archivePath, extractedPath, logger);
184190
try {
185191
(0, proper_lockfile_1.unlockSync)(extractedPath);
186192
}
@@ -226,7 +232,7 @@ function downloadBinary(binaryInfo, options, logger) {
226232
reject(e);
227233
}
228234
try {
229-
const binaryPath = await extractBinary(url, zipFilepath, extractedPath);
235+
const binaryPath = await extractBinary(url, zipFilepath, extractedPath, logger);
230236
resolve(binaryPath);
231237
}
232238
catch (e) {

dist/src/libraries/Executor.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,9 @@ _Executor_instances = new WeakSet(), _Executor_execute = function _Executor_exec
226226
await this.deleteDatabaseDirectory(dbPath);
227227
}
228228
}
229+
catch (e) {
230+
this.logger.error('An erorr occurred while deleting database directory at path:', dbPath, '| The error was:', e);
231+
}
229232
finally {
230233
try {
231234
if (binaryFilepath.includes(os.tmpdir()) && !options.downloadBinaryOnce) {
@@ -237,6 +240,9 @@ _Executor_instances = new WeakSet(), _Executor_execute = function _Executor_exec
237240
await fsPromises.rm(splitPath.join('/'), { force: true, recursive: true });
238241
}
239242
}
243+
catch (e) {
244+
this.logger.error('An error occurred while deleting no longer needed MySQL binary:', e);
245+
}
240246
finally {
241247
if (resolveFunction) {
242248
resolveFunction();

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "mysql-memory-server",
3-
"version": "1.4.0",
3+
"version": "1.4.1",
44
"description": "Spin up an ephemeral MySQL database from your JavaScript code",
55
"main": "dist/src/index.js",
66
"types": "dist/src/index.d.ts",

0 commit comments

Comments
 (0)