diff --git a/package-lock.json b/package-lock.json index 013d739ed..761b98c12 100644 --- a/package-lock.json +++ b/package-lock.json @@ -55,7 +55,6 @@ "@types/tmp": "^0.2.6", "@types/uuid": "^10.0.0", "@types/ws": "^8.5.10", - "@types/wtfnode": "^0.7.3", "@typescript-eslint/eslint-plugin": "^7.1.0", "@typescript-eslint/parser": "^7.1.0", "buffer": "^6.0.3", @@ -85,8 +84,7 @@ "typedoc-plugin-markdown": "^3.17.1", "typedoc-plugin-merge-modules": "^5.1.0", "typedoc-theme-hierarchy": "4.1.2", - "typescript": "^5.3.3", - "wtfnode": "^0.9.3" + "typescript": "^5.3.3" }, "engines": { "node": ">=18.0.0" @@ -3941,12 +3939,6 @@ "@types/node": "*" } }, - "node_modules/@types/wtfnode": { - "version": "0.7.3", - "resolved": "https://registry.npmjs.org/@types/wtfnode/-/wtfnode-0.7.3.tgz", - "integrity": "sha512-UMkHpx+o2xRWLJ7PmT3bBzvIA9/0oFw80oPtY/xO4jfdq+Gznn4wP7K9B/JjMxyxy+wF+5oRPIykxeBbEDjwRg==", - "dev": true - }, "node_modules/@types/yargs": { "version": "17.0.32", "dev": true, @@ -18981,15 +18973,6 @@ } } }, - "node_modules/wtfnode": { - "version": "0.9.3", - "resolved": "https://registry.npmjs.org/wtfnode/-/wtfnode-0.9.3.tgz", - "integrity": "sha512-MXjgxJovNVYUkD85JBZTKT5S5ng/e56sNuRZlid7HcGTNrIODa5UPtqE3i0daj7fJ2SGj5Um2VmiphQVyVKK5A==", - "dev": true, - "bin": { - "wtfnode": "proxy.js" - } - }, "node_modules/xml": { "version": "1.0.1", "dev": true, diff --git a/package.json b/package.json index 4e22b9567..cdaaf7888 100644 --- a/package.json +++ b/package.json @@ -106,7 +106,6 @@ "@types/tmp": "^0.2.6", "@types/uuid": "^10.0.0", "@types/ws": "^8.5.10", - "@types/wtfnode": "^0.7.3", "@typescript-eslint/eslint-plugin": "^7.1.0", "@typescript-eslint/parser": "^7.1.0", "buffer": "^6.0.3", @@ -136,8 +135,7 @@ "typedoc-plugin-markdown": "^3.17.1", "typedoc-plugin-merge-modules": "^5.1.0", "typedoc-theme-hierarchy": "4.1.2", - "typescript": "^5.3.3", - "wtfnode": "^0.9.3" + "typescript": "^5.3.3" }, "optionalDependencies": { "@rollup/rollup-darwin-x64": "^4", diff --git a/src/golem-network/golem-network.ts b/src/golem-network/golem-network.ts index 01b335200..acdb784db 100644 --- a/src/golem-network/golem-network.ts +++ b/src/golem-network/golem-network.ts @@ -40,7 +40,6 @@ import { DataTransferProtocol } from "../shared/types"; import { NetworkApiAdapter } from "../shared/yagna/adapters/network-api-adapter"; import { IProposalRepository } from "../market/proposal"; import { Subscription } from "rxjs"; -import * as wtf from "wtfnode"; /** * Instance of an object or a factory function that you can call `new` on. @@ -354,9 +353,6 @@ export class GolemNetwork { } finally { this.events.emit("disconnected"); this.hasConnection = false; - setTimeout(() => { - wtf.dump(); - }, 20_000); } } diff --git a/tests/examples/examples.test.ts b/tests/examples/examples.test.ts index a55b4a064..4f088da53 100644 --- a/tests/examples/examples.test.ts +++ b/tests/examples/examples.test.ts @@ -2,7 +2,6 @@ import { spawn } from "child_process"; import { dirname, basename, resolve } from "path"; import chalk from "chalk"; import testExamples from "./examples.json"; -import * as wtf from "wtfnode"; const criticalLogsRegExp = [ /GolemInternalError/, /GolemPlatformError/, @@ -25,7 +24,7 @@ async function test(cmd: string, path: string, args: string[] = [], timeout = 36 const file = basename(path); const cwd = dirname(path); const env = { ...process.env, DEBUG: "golem-js:*" }; - const spawnedExample = spawn(cmd, [file, ...args], { cwd, env }); + const spawnedExample = spawn(cmd, [file, ...args], { cwd, env, stdio: ["ignore", "pipe", "pipe"] }); spawnedExample.stdout?.setEncoding("utf-8"); spawnedExample.stderr?.setEncoding("utf-8"); let error = ""; @@ -34,43 +33,39 @@ async function test(cmd: string, path: string, args: string[] = [], timeout = 36 spawnedExample.kill(); }, timeout * 1000); return new Promise((res, rej) => { - const assertLogs = (data: string) => { - console.log(data.trim()); - const logWithoutColors = data.replace( - /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g, - "", - ); - if (criticalLogsRegExp.some((regexp) => logWithoutColors.match(regexp))) { - error = `A critical error occurred during the test. ${logWithoutColors}`; - spawnedExample.kill(); - } - }; - spawnedExample.stdout?.on("data", assertLogs); - spawnedExample.stderr?.on("data", assertLogs); let isFinishing = false; const finishTest = (code?: number, signal?: string) => { - console.log("FINISH TEST", { isFinishing, code, signal, error }); if (isFinishing) { console.log("Test finishing has already been triggered by another event"); return; } + console.log(`Subprocess with test ${file} exited with code ${code} by signal ${signal}`); isFinishing = true; spawnedExample.removeAllListeners(); spawnedExample.stdout.removeAllListeners(); spawnedExample.stderr.removeAllListeners(); clearTimeout(timeoutId); - setTimeout(() => { - wtf.dump(); - }, 20_000); if (!error && !code) return res(true); - rej(`Test example "${file}" failed. Exited with code ${code} by signal ${signal}. ${error}`); + rej(`Test example "${file}" failed. ${error}`); }; - spawnedExample.on("close", finishTest); spawnedExample.on("exit", finishTest); spawnedExample.on("error", (err) => { error = `The test ended with an error: ${err}`; spawnedExample.kill(); }); + const assertLogs = (data: string) => { + console.log(data.trim()); + const logWithoutColors = data.replace( + /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g, + "", + ); + if (criticalLogsRegExp.some((regexp) => logWithoutColors.match(regexp))) { + error = `A critical error occurred during the test. ${logWithoutColors}`; + spawnedExample.kill(); + } + }; + spawnedExample.stdout?.on("data", assertLogs); + spawnedExample.stderr?.on("data", assertLogs); }).finally(() => { clearTimeout(timeoutId); spawnedExample.kill("SIGKILL");