Skip to content
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

fix: remove deno hacky fixes #452

Merged
merged 2 commits into from
Jan 6, 2024
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: 1 addition & 1 deletion .github/workflows/deno.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
# uses: denoland/setup-deno@v1
uses: denoland/setup-deno@61fe2df320078202e33d7d5ad347e7dcfa0e8f31 # v1.1.2
with:
deno-version: v1.x
deno-version: v1.39.2

- name: Compile
run: deno compile --allow-net bin/gamedig.js
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ see next point) and `tshock` (which is `terraria`).
* Added eslint which spotted some unused variables and other lints.
* CLI: Resolved incorrect error message when querying with a non-existent protocol name.
* Added Deno support: the library and CLI can now be experimentally used with the [Deno runtime](https://deno.com)
* Minimum Supported Deno Version: `1.39.2`.
* `deno run --allow-net bin/gamedig.js --type tf2 127.0.0.1`
* Added code examples.

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# node-GameDig - Game Server Query Library [![npmjs.com](https://img.shields.io/npm/dt/gamedig?color=purple)](https://www.npmjs.com/package/gamedig)
# node-GameDig - Game Server Query Library [![npmjs.com](https://img.shields.io/npm/dt/gamedig?color=purple)](https://www.npmjs.com/package/gamedig) ![deno compatibility](https://shield.deno.dev/deno/1.39.2)

**node-GameDig** is a game server query Node.js module (as well as a [command line executable](#usage-from-command-line)),
capable of querying for the status of nearly any game or voice server.
Expand Down
5 changes: 1 addition & 4 deletions lib/GlobalUdpSocket.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@ export default class GlobalUdpSocket {
type: 'udp4',
reuseAddr: true
})
// https://github.com/denoland/deno/issues/20138
if (typeof Deno === "undefined") {
udpSocket.unref();
}
udpSocket.unref()
udpSocket.on('message', (buffer, rinfo) => {
const fromAddress = rinfo.address
const fromPort = rinfo.port
Expand Down
12 changes: 2 additions & 10 deletions lib/QueryRunner.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,21 +68,13 @@ export default class QueryRunner {
for (const attempt of attempts) {
for (let retry = 0; retry < numRetries; retry++) {
attemptNum++
let result

try {
result = await this._attempt(attempt)
return await this._attempt(attempt)
} catch (e) {
e.stack = 'Attempt #' + attemptNum + ' - Port=' + attempt.port + ' Retry=' + (retry) + ':\n' + e.stack
errors.push(e)
} finally {
// Deno doesn't support unref, so we must close the socket after every connection
// https://github.com/denoland/deno/issues/20138
if (typeof Deno !== 'undefined') {
this.udpSocket?.socket?.close()
delete this.udpSocket
}
}
if (result) return result
}
}

Expand Down
Loading