Freeze on await client.login()

import './lib/setup';

import { LogLevel, SapphireClient } from '@sapphire/framework';
import { GatewayIntentBits } from 'discord.js';

const client = new SapphireClient({
defaultPrefix: '!',
caseInsensitiveCommands: true,
logger: {
level: process.env.NODE_ENV === 'development' ? LogLevel.Debug : LogLevel.Info
},
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildVoiceStates,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent,
GatewayIntentBits.GuildMessageReactions
],
loadMessageCommandListeners: true
});

client.on('debug', console.log);

const main = async () => {
try {
client.logger.info('Logging in');
await client.login();
client.logger.info('logged in');
} catch (error) {
client.logger.fatal(error);
await client.destroy();
process.exit(1);
}
};

void main();
import './lib/setup';

import { LogLevel, SapphireClient } from '@sapphire/framework';
import { GatewayIntentBits } from 'discord.js';

const client = new SapphireClient({
defaultPrefix: '!',
caseInsensitiveCommands: true,
logger: {
level: process.env.NODE_ENV === 'development' ? LogLevel.Debug : LogLevel.Info
},
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildVoiceStates,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent,
GatewayIntentBits.GuildMessageReactions
],
loadMessageCommandListeners: true
});

client.on('debug', console.log);

const main = async () => {
try {
client.logger.info('Logging in');
await client.login();
client.logger.info('logged in');
} catch (error) {
client.logger.fatal(error);
await client.destroy();
process.exit(1);
}
};

void main();
[0:38:39] File change detected. Starting incremental compilation...

[0:38:39] Found 0 errors. Watching for file changes.


> node dist/index.js

2025-01-20 00:38:41 - INFO - Logging in
[0:38:39] File change detected. Starting incremental compilation...

[0:38:39] Found 0 errors. Watching for file changes.


> node dist/index.js

2025-01-20 00:38:41 - INFO - Logging in
The log before firing the login function is displayed, but after that nothing happens. I have set up a debug log, but nothing is displayed.
85 Replies
Lami
LamiOP4d ago
Hardcoding a token or giving an appropriate string to a function as a token does not change the result Adding the file “ヘルプ.ts” to the commands folder seems to cause this condition. I think this is a bug and will file an issue.
kyra
kyra3d ago
I’ll investigate this after I get back home (in around 6 hours) @Lami that's interesting, failing with Katakana but working with Kanji Does it also work with Hiragana?
kyra
kyra3d ago
Seems to be working for me with Katakana
No description
No description
kyra
kyra3d ago
Can you provide me the source of the command? See if it has something that may stop it from working If you rewrite the Kanji command's file name to Katakana, does it work?
Lami
LamiOP3d ago
https://github.com/c7e715d1b04b17683718fb1e8944cc28/my-sapphire-bot I uploaded a project that does not work to Github as public!
GitHub
GitHub - c7e715d1b04b17683718fb1e8944cc28/my-sapphire-bot
Contribute to c7e715d1b04b17683718fb1e8944cc28/my-sapphire-bot development by creating an account on GitHub.
Lami
LamiOP3d ago
This is only a guess, but Japanese Windows uses Shift-JIS instead of UTF-8. I just re-tested “Hiragana” and “Kanji” and it stopped working on both.
kyra
kyra3d ago
I'll check regardless
kyra
kyra3d ago
It's still loading for me @Lami
No description
No description
kyra
kyra3d ago
And firing ready Uhm... I have no idea how to test that, sadly 😅
kyra
kyra3d ago
I do see this tho
No description
kyra
kyra3d ago
I did find this, however: https://answers.microsoft.com/en-us/windows/forum/all/file-explorer-not-displaying-japanese-characters/c6f8dbb6-bf89-4bc0-9c9e-ca7b4c3ef542 Nevertheless, can you change line 10 in your index.ts
- level: LogLevel.Debug
+ level: LogLevel.Trace
- level: LogLevel.Debug
+ level: LogLevel.Trace
And check the logs searching for => commands in the terminal?
Lami
LamiOP3d ago
I imitated it and set Log to Trace and got an error message. I hope this helps,
kyra
kyra3d ago
Is that where it ends at?
kyra
kyra3d ago
It doesn't even show the lines for the JS files
No description
Lami
LamiOP3d ago
Yes, this should be all.
No description
kyra
kyra3d ago
Lami
LamiOP3d ago
I know of it, but have never used it. I am sorry.
kyra
kyra3d ago
For this, you would have to set a breakpoint in the line 40 from LoaderStrategy, then fire the bot with F5/Ctrl+Shift+D Then skip a few times until you reach the command that's written in Katakana
kyra
kyra3d ago
Debugging in Visual Studio Code
One of the great things in Visual Studio Code is debugging support. Set breakpoints, step-in, inspect variables and more.
Lami
LamiOP3d ago
Thank you. I'll try.
kyra
kyra3d ago
I'm also down for screen sharing on Discord, since VSCode's sharing won't work on gitignored files (such as node_modules), and enabling it would allow me to see .env, so I wouldn't recommend it 😅
Lami
LamiOP3d ago
Does this seem to be working?
No description
kyra
kyra3d ago
Yes! Look for the value of path$1 in the top left
kyra
kyra3d ago
You can expand it to see the full path
No description
kyra
kyra3d ago
btw to make it easier, remove all the breakpoints except line 34
kyra
kyra3d ago
That way when you hit that button, it'll jump to the next file
No description
Lami
LamiOP3d ago
How about this?
No description
kyra
kyra3d ago
Yes! Now press this button
No description
kyra
kyra3d ago
That'll move it to the next statement I would like to see if extension and name are assigned correctly They should be .js and ヘルプ respectively
Lami
LamiOP3d ago
Is this correct?
No description
kyra
kyra3d ago
Yes :) And I know that line 38 won't return null, so next relevant bit is a breakpoint on line 50 until you find the same file, remember to remove the breakpoint from filter ^^
Lami
LamiOP3d ago
Is this okay?
No description
kyra
kyra3d ago
You can expand file in the variables to see which file it's on
Lami
LamiOP3d ago
No description
kyra
kyra3d ago
Or under ウォッチ式, add a new variable of file.name Oki, that looks good Go to the next statement to see if it loads
Lami
LamiOP3d ago
Error
No description
Lami
LamiOP3d ago
Are you saying that the cause is the current location?
kyra
kyra3d ago
Uhmmmmmmmmmmmm this is interesting Could you show your screen in a voice channel? #Coding 0 for instance, you can keep yourself muted or even deafened if you want to, it's mostly to see it live and guide you a little better and faster than screenshots
Lami
LamiOP3d ago
Okay, I'm in another voice chat now, so can we do this a little later?
kyra
kyra3d ago
Sure :)
Lami
LamiOP3d ago
Thank you very much! We apologize for the inconvenience.
kyra
kyra2d ago
Ping me when you're available for debugging more please I really hope this isn't a bug from Node.js 😅 I transferred the issue to /pieces and wrote a status message on it, @Lami As a heads up :)
Lami
LamiOP2d ago
Thank you! @kyra 🩵🩷🤍🩷🩵 It is possible now! But I am very poor in English, so can we communicate by text while sharing the screen?
kyra
kyra2d ago
Sure :) Alright, can you debug again until it reaches the same file? No need to repeat filter Alright, now instead of the 2nd button, press the 3rd Uhm... can you go to the built JS file and place a breakpoint there as well? Just in case
Lami
LamiOP2d ago
index.js?
kyra
kyra2d ago
In dist/commands/ Yes that one, just a breakpoint on line 2 Uhmmmmmmmmmm Can you copy the path and do require() with it? Somewhere in your index, to see if Node.js can load it That won't quite work You need \\ Breakpoint on line 15 just in case And that'll be good to go :) Ok, Node.js can't load the file at all Lemme find a way to convert it to CP932 so we can load it much like the OS is expecting
Lami
LamiOP2d ago
Okay!
kyra
kyra2d ago
Replace the name with ヘルãƒ? No no, in your terminal You don't need to replace the file name or something I'm re-encoding the string to see what can load it I pretty much got those: - ƒwƒ‹ƒv - 荷莋荶� - ヘルãƒ? - 飣莫� So I would like to try if any of the 4 options can load ヘルプ.js You can do that in your terminal, no need to run VSCode's debugger for this :) Uhm...
Lami
LamiOP2d ago
https://github.com/nodejs/node/issues/55773 I did a little searching and found this issue on Node Does it seem relevant?
GitHub
node.js responds nothing and even no error when executing *.js file...
Version v22.5.0 Platform Microsoft Windows NT 10.0.19045.0 x64 Microsoft Windows NT 10.0.22631.0 x64 Subsystem No response What steps will reproduce the bug? Run a cmd.exe. Run command mkdir "...
kyra
kyra2d ago
Yeah I saw, uhmmmmmmmmmmmm It's starting to look like a Node.js bug :( And it doesn't look like we can work around it by pre-recoding the path so when Node.js re-encodes it, it turns out fine What Node.js version are you on? I saw 22. something
Lami
LamiOP2d ago
22.11.0!
kyra
kyra2d ago
Latest is 22.13.0 Maybe you can try that version or 23.6.0, see if either fixes it? If you use something like Volta, it's trivial to install and run new versions ^^
Lami
LamiOP2d ago
Ok, I will try it! But I don't think I have a version control tool installed, so it may take a bit of time to change the version! I will try to install Volta.
kyra
kyra2d ago
You can try to install Volta later, that needs you to uninstall Node.js in the first place 😅 To test it quickly you can update to 22.13.0, see if it's fixed in that version From what I'm seeing it's C++ std::filesystem::path's fault, and latest versions remove it from Node.js's code https://github.com/nodejs/node/issues/56049#issuecomment-2507881729 Uhmmmmmmmmmmmmmmmmmmmmmmmmm
Lami
LamiOP2d ago
I'll try 23.6.0.
kyra
kyra2d ago
s!ev const b = buffer.Buffer.from(C:\\path\\to\\ヘルプ.js, 'utf8'); const decoder = new util.TextDecoder('shift_jis'); [decoder.encoding, buffer.Buffer.from(decoder.decode(b), 'binary').toString('binary')];
Skyra
Skyra2d ago
Output: ⏱ 427.64μs
[ 'shift_jis', 'C:\\path\\to\\]%\x9D]ý.js' ]
[ 'shift_jis', 'C:\\path\\to\\]%\x9D]ý.js' ]
kyra
kyra2d ago
Yeah... I don't think I can make this work :(, this looks like a Node.js bug
Lami
LamiOP2d ago
Okay, thank you for seeking a solution! Just knowing the cause was helpful.
kyra
kyra2d ago
There are two workarounds available from what I have seen
kyra
kyra2d ago
Although I don't know what implications it has to switch that... probably wouldn't touch that without a backup I'm curious whether Deno can run that :iara_think_thonk: Sapphire supports Deno and Bun too, if Node.js can't, maybe you can try those
Lami
LamiOP2d ago
Ahhhhhh, I used to use UTF-8 in my system, but I am very unsure if I should activate that setting, as it caused enormous bugs in my old software.
kyra
kyra2d ago
Yeah... probably not a good idea, so we're left to the last workarounds of using either Deno or Bun and see if either can make it work
Lami
LamiOP2d ago
Okay, I'll try it!
kyra
kyra2d ago
Alright let's see if it loaded the command+
Lami
LamiOP2d ago
Progress made!
kyra
kyra2d ago
0 commands though :iara_think_thonk: Why is it using require Add "type": "module" in your package.json Yeah that needs a rebuild... or run the TS code It's trying to walk over the JS files OH package.json's main Replace dist with src Yes
Lami
LamiOP2d ago
!!!
kyra
kyra2d ago
There we go!
Lami
LamiOP2d ago
Working!
kyra
kyra2d ago
:LenaEcstatic: We finally did it So it is indeed a Node.js bug
Lami
LamiOP2d ago
Thank you very much!
kyra
kyra2d ago
You tried with both Node.js v22.13.0 and 23.6.0, right?
Lami
LamiOP2d ago
Yes
kyra
kyra2d ago
I can file the issue for you if you want, and send you the link so you can subscribe to updates
Lami
LamiOP2d ago
i would like to subscribe
kyra
kyra2d ago
Thank you for letting me help you with this, it would have been much harder to find out the issue without the screen share :LenaSmile: I'll prepare some food and then write the issue + send it here :)
Lami
LamiOP2d ago
Thank you very much! I am going to get some sleep now as it is already morning before I know it. I will check the issue when I wake up!
kyra
kyra2d ago
Alright, have a nice sleep!
kyra
kyra2d ago
GitHub
fs: can't require non-ASCII file paths in Shift-JIS filesystem · Is...
Version v22.13.0, v23.6.0 Platform Microsoft Windows NT 10.0.26100.0 x64 Subsystem fs What steps will reproduce the bug? Use Japanese Windows with Shift-JIS (aka CP932) Load a non-ASCII file path w...
Lami
LamiOP2d ago
Thank you!
Favna
Favna2d ago
I think we can pretty much close this thread? Not much we can do and nothing we have to do once Node fixes the problem.
kyra
kyra2d ago
If @Lami is fine with us marking this as "solved"/closing the thread, yeah
Lami
LamiOP2d ago
No problem!

Did you find this page helpful?