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

Deno Support #9663

Closed
2 tasks done
7xa5h opened this issue Jun 23, 2023 · 26 comments
Closed
2 tasks done

Deno Support #9663

7xa5h opened this issue Jun 23, 2023 · 26 comments

Comments

@7xa5h
Copy link

7xa5h commented Jun 23, 2023

Which application or package is this feature request for?

discord.js

Feature

Deno, which is a Node.js successor, is a very popular runtime for JavaScript and TypeScript, while I know that most people still use Node.js as its the "industry standard" I also think DJS should add Deno support as it would be pretty easy - I'm not sure, I'm not an expert - and Deno also released NPM package support a long time ago, which would further help here.

I'm pretty sure this wouldnt require a new major version but more of a minor release, as its not that big of a thing imo, Deno is pretty close to how Node.js is and it should be pretty easy, I know lots of people also posted issues like this but I'm trying to get more into detail.

Ideal solution or implementation

To fix this I'd recommend trying to either make a new version of DJS on Denos package registery deno.land/x/ and/or adding support for Deno in the existing NPM library.

Alternative solutions or implementations

You could also simply iron out the bugs that Deno is facing with importing "npm:discord.js" and it would be basically kind of the same fix.

Other context

No response

Tasks

  1. feature request packages:ws
  2. invalid packages:discord.js
@vladfrangu
Copy link
Member

Dupe of #7065 😄

@7xa5h
Copy link
Author

7xa5h commented Jun 23, 2023

Dupe of #7065 😄

I know, but that issue doesn't specifically mention how Deno has NPM support now and it would be way easier to implement without having to find other 3rd party libraries and packages.

@Jiralite Jiralite changed the title Deno Support. Deno Support Jun 25, 2023
@7xa5h
Copy link
Author

7xa5h commented Jul 12, 2023

Apparently Deno1.35 now supports discord.js along with some other NPM packages, however, it seems like undici is specifically not working on windows only.

After doing some testing, Deno works on the following systems:

  • Windows
  • MacOS
  • Most Linux Distros

Here's a related issue: denoland/deno#19766

@imranbarbhuiya
Copy link
Contributor

check #9683

@Erisfiregamer1
Copy link

Should be closable now- no-de-no-de is merged, which will prevent this issue. Probably.

@Erisfiregamer1
Copy link

Nope, not fixed. 1.35.1's regression breaks compatibility anyway, and any version below 1.35.0 just returns an API error. :(

@vladfrangu
Copy link
Member

vladfrangu commented Jul 17, 2023

Try the @dev versions. That should work

@Erisfiregamer1
Copy link

Erisfiregamer1 commented Jul 17, 2023

@dev is what I'm using, silly.

Here's the error:

{
  error: Error: Unexpected server response: 404
    at HttpsClientRequest.<anonymous> (file:///C:/Users/[redacted]/AppData/Local/deno/npm/registry.npmjs.org/ws/8.13.0/lib/websocket.js:888:7)
    at HttpsClientRequest.emit (ext:deno_node/_stream.mjs:1852:9)
    at ext:deno_node/http.ts:476:18
    at eventLoopTick (ext:core/01_core.js:182:11)
}

@Erisfiregamer1
Copy link

For now, a mitigation strategy is to deno upgrade --version 1.35.0 because that version is confirmed to work fine with Deno. I'll cherrypick through commits to see which one did this...

@vladfrangu
Copy link
Member

Noo, I see the issue. @dev builds haven't published yet, so the no-de-no-de branch isn't out on npm yet.

@Erisfiregamer1
Copy link

Erisfiregamer1 commented Jul 17, 2023

Aghhhhhhh! Why does it fail with a different error then?! Damn you, Deno and randomly breaking!

I'll just grab the file from CI and use that.

EDIT: Or you could just manually push dev, yeah, works too

@Erisfiregamer1
Copy link

Aha, no. It returns the EXACT SAME ERROR on discord.js@14.11.1-dev.1689600799-afa9879.0

@7xa5h
Copy link
Author

7xa5h commented Jul 17, 2023

Aha, no. It returns the EXACT SAME ERROR on discord.js@14.11.1-dev.1689600799-afa9879.0

hm so now the latest version of discord.js (when its published to npm) should fix the issue with Deno 1.35.0 and 1.35.1, right?

@Erisfiregamer1
Copy link

No, it's not fixed at all.

1.35.0 is fixed on npm:discord.js@dev (Windows), so use 1.35.0.
1.35.1 introduced a different regression that djs couldn't fix.

@7xa5h
Copy link
Author

7xa5h commented Jul 17, 2023

No, it's not fixed at all.

1.35.0 is fixed on npm:discord.js@dev (Windows), so use 1.35.0. 1.35.1 introduced a different regression that djs couldn't fix.

well then when will we stop having to use @dev?

@Erisfiregamer1
Copy link

Once discord.js makes a new release

@7xa5h
Copy link
Author

7xa5h commented Jul 17, 2023

Once discord.js makes a new release

hm, ive tested both @dev and @latest, with deno 1.35.0 and 1.35.1 and all 4 of them seem to not work for now.
Im still getting the same abort error from undici timing out

@Erisfiregamer1
Copy link

are you sure you're on @dev? doesn't happen to me

@7xa5h
Copy link
Author

7xa5h commented Jul 17, 2023

are you sure you're on @dev? doesn't happen to me

yep, heres my code:

import { Client, GatewayIntentBits, Partials } from "npm:discord.js@dev";
import config from "./config.json" assert { type: "json" };

const client = new Client({
  intents: [
    GatewayIntentBits.Guilds,
    GatewayIntentBits.GuildMembers,
    GatewayIntentBits.GuildMessages,
  ],
  partials: [
    Partials.Channel,
    Partials.GuildMember,
    Partials.Reaction,
    Partials.ThreadMember,
    Partials.User,
  ],
});

client.config = config;

client
  .login(config.token)
  .then(() => console.log(`🟩 [LOGIN] Client logged in.`))
  // .catch((err) => console.error(`🟥 [LOGIN] ${err}`));

err:

    at abort (file:///C:/Users/xash/AppData/Local/deno/npm/registry.npmjs.org/undici/5.22.1/lib/api/abort-signal.js:10:18)
    at AbortSignal.self.<computed> (file:///C:/Users/xash/AppData/Local/deno/npm/registry.npmjs.org/undici/5.22.1/lib/api/abort-signal.js:29:5)
    at innerInvokeEventListeners (ext:deno_web/02_event.js:792:7)
    at invokeEventListeners (ext:deno_web/02_event.js:839:5)
    at dispatch (ext:deno_web/02_event.js:696:9)
    at AbortSignal.dispatchEvent (ext:deno_web/02_event.js:1101:12)
    at AbortSignal.[[[signalAbort]]] (ext:deno_web/03_abort_signal.js:97:10)
    at AbortController.abort (ext:deno_web/03_abort_signal.js:170:30)
    at Timeout._onTimeout (file:///C:/Users/xash/AppData/Local/deno/npm/registry.npmjs.org/@discordjs/rest/1.7.1/dist/index.js:589:71)
    at cb (ext:deno_node/internal/timers.mjs:60:31)

Deno 1.35.0, Windows 11 Lite (basically Tiny 11)

@Erisfiregamer1
Copy link

Not sure if W11 Lite is the problem. All I know is stock Windows 11 works fine.

@suneettipirneni
Copy link
Member

Can you verify that the latest dev release is using fetch instead of undici for deno?

@7xa5h
Copy link
Author

7xa5h commented Jul 18, 2023

Can you verify that the latest dev release is using fetch instead of undici for deno?

well not in my case as you can clearly see undici in the error log, ill check the latest dev version tmr tho

@Erisfiregamer1
Copy link

Deno has pushed a commit to patch the regression in 1.35.1, next Deno release will be able to natively run discord.js.

For now, deno upgrade --canary will move you to the patched version of Deno.

@vladfrangu
Copy link
Member

For what it's worth, once we release new versions of all modules you also can do that 😄

@Erisfiregamer1
Copy link

Nope- it's not working for everyone on @dev. It seems to be local to 7xa5h- BUT some things use the Node ws module, which is unreliable on Deno to say the least.

@7xa5h
Copy link
Author

7xa5h commented Jul 19, 2023

Nope- it's not working for everyone on @dev. It seems to be local to 7xa5h- BUT some things use the Node ws module, which is unreliable on Deno to say the least.

do i close the issue now? i mean its practically fixed from both sides now

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants