Skip to content

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

@gear4s

Description

@gear4s

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions