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

fs.stat() fully blocking with await, forever #60

Open
gear4s opened this issue Nov 26, 2017 · 1 comment
Open

fs.stat() fully blocking with await, forever #60

gear4s opened this issue Nov 26, 2017 · 1 comment

Comments

@gear4s
Copy link

gear4s commented Nov 26, 2017

This is my code:

const fs = require('mz/fs');
const modules = []
client.on("ready", async () => {
  console.log("Logged in to discord!");
  client.user.setGame("!help")

  // start loading modules
  const files = await fs.readdir("./modules").catch(e => {
    console.error("Module directory could not be found, aborting", argv.debug ? `\n${error}` : "")
    process.exit( 1 )
  })
  for(const file of files) {
    // Make one pass and make the file complete
    const stat = await fs.stat(`./modules/${file}`).catch(e => {
      console.error("Error stating file.", argv.debug ? `\n${e}` : "")
    })

    if(stat.isDirectory()) {
      return
    }

    debug(`Loaded ./modules/${file}`)
    const mod = require(`./modules/${file}`)
    mod.init(client)
    modules.push(mod)
  };
  console.log(`Bot started successfully, ${modules.length} modules loaded`)
});

it never gets to even print the last console.log, no matter how long I leave it to run

@jonathanong
Copy link
Contributor

probably because it's throwing an error. be sure to handle your errors

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants