From d7f06975a68433d9f071cef02bbc342cbfbfd6ae Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Mon, 1 Feb 2021 11:06:49 -0500 Subject: [PATCH] test: Switch from leaked-handles to wtfnode (#2604) See my comments at https://github.com/cdr/code-server/pull/2563#issuecomment-763394741 --- package.json | 2 ++ test/socket.test.ts | 4 +++- test/wtfnode.ts | 19 +++++++++++++++++++ yarn.lock | 10 ++++++++++ 4 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 test/wtfnode.ts diff --git a/package.json b/package.json index 364cfe0b..e94e0668 100644 --- a/package.json +++ b/package.json @@ -47,6 +47,7 @@ "@types/tar-fs": "^2.0.0", "@types/tar-stream": "^2.1.0", "@types/ws": "^7.2.6", + "@types/wtfnode": "^0.7.0", "@typescript-eslint/eslint-plugin": "^4.7.0", "@typescript-eslint/parser": "^4.7.0", "doctoc": "^1.4.0", @@ -61,6 +62,7 @@ "stylelint": "^13.0.0", "stylelint-config-recommended": "^3.0.0", "ts-node": "^9.0.0", + "wtfnode": "^0.8.4", "typescript": "^4.1.3" }, "resolutions": { diff --git a/test/socket.test.ts b/test/socket.test.ts index 9ff5038e..aadf86b4 100644 --- a/test/socket.test.ts +++ b/test/socket.test.ts @@ -1,14 +1,16 @@ import { field, logger } from "@coder/logger" import * as fs from "fs-extra" -import "leaked-handles" import * as net from "net" import * as path from "path" import * as tls from "tls" import { Emitter } from "../src/common/emitter" import { SocketProxyProvider } from "../src/node/socket" import { generateCertificate, tmpdir } from "../src/node/util" +import * as wtfnode from "./wtfnode" describe("SocketProxyProvider", () => { + wtfnode.setup() + const provider = new SocketProxyProvider() const onServerError = new Emitter<{ event: string; error: Error }>() diff --git a/test/wtfnode.ts b/test/wtfnode.ts new file mode 100644 index 00000000..2dfce59a --- /dev/null +++ b/test/wtfnode.ts @@ -0,0 +1,19 @@ +import * as wtfnode from "wtfnode" + +let active = false + +export function setup(): void { + if (active) { + return + } + active = true + + const interval = 5000 + const wtfnodeDump = () => { + wtfnode.dump() + const t = setTimeout(wtfnodeDump, interval) + t.unref() + } + const t = setTimeout(wtfnodeDump, interval) + t.unref() +} diff --git a/yarn.lock b/yarn.lock index d692116e..cb51b991 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1201,6 +1201,11 @@ dependencies: "@types/node" "*" +"@types/wtfnode@^0.7.0": + version "0.7.0" + resolved "https://registry.yarnpkg.com/@types/wtfnode/-/wtfnode-0.7.0.tgz#e5d9c675bccc2f786830ffa40ffe8865f92057d9" + integrity sha512-kdBHgE9+M1Os7UqWZtiLhKye5reFl8cPBYyCsP2fatwZRz7F7GdIxIHZ20Kkc0hYBfbXE+lzPOTUU1I0qgjtHA== + "@typescript-eslint/eslint-plugin@^4.7.0": version "4.7.0" resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.7.0.tgz#85c9bbda00c0cb604d3c241f7bc7fb171a2d3479" @@ -8022,6 +8027,11 @@ ws@^7.2.0: resolved "https://registry.yarnpkg.com/ws/-/ws-7.3.1.tgz#d0547bf67f7ce4f12a72dfe31262c68d7dc551c8" integrity sha512-D3RuNkynyHmEJIpD2qrgVkc9DQ23OrN/moAwZX4L8DfvszsJxpjQuUq3LMx6HoYji9fbIOBY18XWBsAux1ZZUA== +wtfnode@^0.8.4: + version "0.8.4" + resolved "https://registry.yarnpkg.com/wtfnode/-/wtfnode-0.8.4.tgz#91ecf78a40ce222a73a063f26d72bea52357efcc" + integrity sha512-64GEKtMt/MUBuAm+8kHqP74ojjafzu00aT0JKsmkIwYmjRQ/odO0yhbzKLm+Z9v1gMla+8dwITRKzTAlHsB+Og== + x-is-string@^0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/x-is-string/-/x-is-string-0.1.0.tgz#474b50865af3a49a9c4657f05acd145458f77d82"