Skip to content

Commit

Permalink
perf(net): use builtin ws impl
Browse files Browse the repository at this point in the history
- Upgrade Electron to beta version for Node.js v22.
- Add warnings tracing flag to instrumented tests.
- Replace WebSocket impl with builtin module.
- Remove ws package.
  • Loading branch information
skjsjhb committed Jan 18, 2025
1 parent 9fc4fbe commit 62a723f
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 56 deletions.
2 changes: 1 addition & 1 deletion build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ if (mode === "test") {
const xvfbExec = path.resolve(import.meta.dirname, "node_modules", "xvfb-maybe", "src", "xvfb-maybe.js");
const electronExec = path.resolve(import.meta.dirname, "node_modules", "electron", "cli.js");
const cwd = path.resolve(import.meta.dirname, "build", "prod");
const proc = child_process.fork(xvfbExec, [electronExec, "."], { cwd });
const proc = child_process.fork(xvfbExec, [electronExec, "--trace-warnings", "."], { cwd });

proc.once("exit", () => {
const f = path.join(cwd, "test-summary.json");
Expand Down
4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,12 @@
"@types/react": "^18.3.18",
"@types/react-dom": "^18.3.5",
"@types/uuid": "^10.0.0",
"@types/ws": "^8.5.13",
"@vitejs/plugin-react-swc": "^3.7.2",
"@vitest/coverage-v8": "^2.1.8",
"chai-as-promised": "^8.0.1",
"consola": "^3.3.3",
"cross-env": "^7.0.3",
"electron": "^33.3.1",
"electron": "^35.0.0-alpha.1",
"esbuild": "^0.24.2",
"shx": "^0.3.4",
"tailwindcss": "^3.4.17",
Expand Down Expand Up @@ -74,7 +73,6 @@
"superserial": "^0.3.5",
"uuid": "^11.0.3",
"wouter": "^3.3.5",
"ws": "^8.18.0",
"yaml": "^2.7.0"
},
"packageManager": "[email protected]+sha512.f18a59ca3611002321af7681e6d49234cb3ece8496b05818be5b1081168ec21b8c3d28cbb4351e2fdec66ca95e6516faaf08b95b755013c88cf5174d5029865c"
Expand Down
59 changes: 10 additions & 49 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions src/main/net/aria2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import { pEvent } from "p-event";
import path from "path";
import type TypedEventEmitter from "typed-emitter";
import type TypedEmitter from "typed-emitter";
import { WebSocket } from "ws";

let aria2cProcess: childProcess.ChildProcess | null = null;
let aria2cToken: string | null = null;
Expand Down Expand Up @@ -97,7 +96,7 @@ async function sendRequest(req: Aria2DownloadRequest): Promise<void> {
...checksum
}
]) as Promise<string>;

if (req.signal) {
Promise.all([getGid, pEvent(req.signal, "abort")]).then(([lateGID]) => remove(lateGID));
}
Expand Down
1 change: 0 additions & 1 deletion src/main/net/rpc.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import EventEmitter from "events";
import { nanoid } from "nanoid";
import { type WebSocket } from "ws";

export class WebSocketJsonRpcClient {
// This implementation uses third-party WebSocket implementation
Expand Down

0 comments on commit 62a723f

Please sign in to comment.