Skip to content

test: Switch from leaked-handles to wtfnode #2604

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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": {
Expand Down
4 changes: 3 additions & 1 deletion test/socket.test.ts
Original file line number Diff line number Diff line change
@@ -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 }>()
Expand Down
19 changes: 19 additions & 0 deletions test/wtfnode.ts
Original file line number Diff line number Diff line change
@@ -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()
}
10 changes: 10 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down