Skip to content

Commit

Permalink
fix: dest.end is not a function (#501)
Browse files Browse the repository at this point in the history
  • Loading branch information
louis-jan authored Oct 31, 2023
1 parent f35c97b commit 1efe2cb
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 12 deletions.
15 changes: 10 additions & 5 deletions electron/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const progress = require("request-progress");
const { autoUpdater } = require("electron-updater");
const Store = require("electron-store");

const requiredModules: Record<string, any> = {};
let requiredModules: Record<string, any> = {};
let mainWindow: BrowserWindow | undefined = undefined;

app
Expand All @@ -39,12 +39,12 @@ app
});

app.on("window-all-closed", () => {
dispose(requiredModules);
clearImportedModules();
app.quit();
});

app.on("quit", () => {
dispose(requiredModules);
clearImportedModules();
app.quit();
});

Expand Down Expand Up @@ -226,7 +226,7 @@ function handleIPCs() {
* @param url - The URL to reload.
*/
ipcMain.handle("relaunch", async (_event, url) => {
dispose(requiredModules);
clearImportedModules();

if (app.isPackaged) {
app.relaunch();
Expand Down Expand Up @@ -255,7 +255,7 @@ function handleIPCs() {

rmdir(fullPath, { recursive: true }, function (err) {
if (err) console.log(err);
dispose(requiredModules);
clearImportedModules();

// just relaunch if packaged, should launch manually in development mode
if (app.isPackaged) {
Expand Down Expand Up @@ -394,3 +394,8 @@ function setupPlugins() {
pluginsPath: join(app.getPath("userData"), "plugins"),
});
}

function clearImportedModules() {
dispose(requiredModules);
requiredModules = {};
}
4 changes: 2 additions & 2 deletions plugins/inference-plugin/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const { app } = require("electron");
const { spawn } = require("child_process");
const fs = require("fs");
const tcpPortUsed = require("tcp-port-used");
const { killPortProcess } = require("kill-port-process");
const kill = require("kill-port");

const PORT = 3928;
let subprocess = null;
Expand Down Expand Up @@ -99,7 +99,7 @@ function killSubprocess() {
subprocess = null;
console.log("Subprocess terminated.");
} else {
killPortProcess(PORT);
kill(PORT, "tcp").then(console.log).catch(console.log);
console.error("No subprocess is currently running.");
}
}
Expand Down
10 changes: 5 additions & 5 deletions plugins/inference-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,21 @@
},
"dependencies": {
"@janhq/core": "^0.1.6",
"kill-port-process": "^3.2.0",
"kill-port": "^2.0.1",
"rxjs": "^7.8.1",
"tcp-port-used": "^1.0.2",
"ts-loader": "^9.5.0"
},
"bundledDependencies": [
"tcp-port-used",
"kill-port-process"
],
"engines": {
"node": ">=18.0.0"
},
"files": [
"dist/*",
"package.json",
"README.md"
],
"bundleDependencies": [
"tcp-port-used",
"kill-port"
]
}
3 changes: 3 additions & 0 deletions plugins/inference-plugin/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,8 @@ module.exports = {
resolve: {
extensions: [".ts", ".js"],
},
optimization: {
minimize: false,
},
// Add loaders and other configuration as needed for your project
};
3 changes: 3 additions & 0 deletions plugins/monitoring-plugin/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,8 @@ module.exports = {
resolve: {
extensions: [".ts", ".js"],
},
optimization: {
minimize: false,
},
// Add loaders and other configuration as needed for your project
};

0 comments on commit 1efe2cb

Please sign in to comment.