最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Discord.js: AbortError: The user aborted a request - Stack Overflow

programmeradmin0浏览0评论

I have been working on my ticket system and its transcript logging process, and one day this error started showing up and transcripts started to fail sending. This didn't use to be a thing before. The full error is:

[Error Handling System] Multiple Resolves
reject Promise {
  <rejected> AbortError: The user aborted a request.
      at abort (/PC/Bot/bot/node_modules/discord.js/node_modules/node-fetch/lib/index.js:1448:16)
      at EventTarget.abortAndFinalize (/PC/Bot/bot/node_modules/discord.js/node_modules/node-fetch/lib/index.js:1463:4)
      at EventTarget.[nodejs.internal.kHybridDispatch] (node:internal/event_target:460:20)
      at EventTarget.dispatchEvent (node:internal/event_target:405:26)
      at abortSignal (node:internal/abort_controller:97:10)
      at AbortController.abort (node:internal/abort_controller:122:5)
      at Timeout.<anonymous> (/PC/Bot/bot/node_modules/discord.js/src/rest/APIRequest.js:72:49)
      at listOnTimeout (node:internal/timers:557:17)
      at processTimers (node:internal/timers:500:7) {
    type: 'aborted'
  }
}

My code is:

setTimeout(() => {
    interaction.channel.delete({ reason: `[Ticket System] Ticket Closed` }).then(async ch => {
      const mdb = require('./../models/tickets')
      mdb.findOne({ Channel: ch.id }, async (err, data) => {
        if (err) throw err;
        if (data) {
          const openedBy = interaction.guild.members.cache.get(ch.topic.split(" ").splice(1).toString())
          fs.writeFileSync(`../${ch.name} - ${ch.id}.txt`, data.Content.join("\n\n"))
          let embed = new Discord.MessageEmbed()
            .setTitle("Ticket Closed")
            .addField("<:ticket1:872962350473433089> Ticket Name", `${ch.name} (${ch.id})`)
            .addField(`<:person:890913045457563718> Opened By`, `${openedBy}`)
            .addField("<:admin:872930262516908113> Closed By", `${interaction.user} (${interaction.user.id})`)
            .addField(`<:open:914148680959934514> Open Time`, `<t:${moment(ch.createdTimestamp).format("X")}>`)
            .setTimestamp()
            .setFooter({ text: `ID: ${uuidv4()}` })
          const atta = new Discord.MessageAttachment(fs.createReadStream(`../${ch.name}-${ch.id}.txt`))
          const logChannel = client.channels.cache.get(transcripts_channel);
          logChannel.send({ embeds: [embed], files: [atta] })
          mdb.findOneAndDelete({ Channel: ch.id })
        }
      })
    })
  }, 10000)

I have tried removing MongoDB parts, tried decreasing the timeout and many more... None of those helped.

Thanks in advance!

I have been working on my ticket system and its transcript logging process, and one day this error started showing up and transcripts started to fail sending. This didn't use to be a thing before. The full error is:

[Error Handling System] Multiple Resolves
reject Promise {
  <rejected> AbortError: The user aborted a request.
      at abort (/PC/Bot/bot/node_modules/discord.js/node_modules/node-fetch/lib/index.js:1448:16)
      at EventTarget.abortAndFinalize (/PC/Bot/bot/node_modules/discord.js/node_modules/node-fetch/lib/index.js:1463:4)
      at EventTarget.[nodejs.internal.kHybridDispatch] (node:internal/event_target:460:20)
      at EventTarget.dispatchEvent (node:internal/event_target:405:26)
      at abortSignal (node:internal/abort_controller:97:10)
      at AbortController.abort (node:internal/abort_controller:122:5)
      at Timeout.<anonymous> (/PC/Bot/bot/node_modules/discord.js/src/rest/APIRequest.js:72:49)
      at listOnTimeout (node:internal/timers:557:17)
      at processTimers (node:internal/timers:500:7) {
    type: 'aborted'
  }
}

My code is:

setTimeout(() => {
    interaction.channel.delete({ reason: `[Ticket System] Ticket Closed` }).then(async ch => {
      const mdb = require('./../models/tickets')
      mdb.findOne({ Channel: ch.id }, async (err, data) => {
        if (err) throw err;
        if (data) {
          const openedBy = interaction.guild.members.cache.get(ch.topic.split(" ").splice(1).toString())
          fs.writeFileSync(`../${ch.name} - ${ch.id}.txt`, data.Content.join("\n\n"))
          let embed = new Discord.MessageEmbed()
            .setTitle("Ticket Closed")
            .addField("<:ticket1:872962350473433089> Ticket Name", `${ch.name} (${ch.id})`)
            .addField(`<:person:890913045457563718> Opened By`, `${openedBy}`)
            .addField("<:admin:872930262516908113> Closed By", `${interaction.user} (${interaction.user.id})`)
            .addField(`<:open:914148680959934514> Open Time`, `<t:${moment(ch.createdTimestamp).format("X")}>`)
            .setTimestamp()
            .setFooter({ text: `ID: ${uuidv4()}` })
          const atta = new Discord.MessageAttachment(fs.createReadStream(`../${ch.name}-${ch.id}.txt`))
          const logChannel = client.channels.cache.get(transcripts_channel);
          logChannel.send({ embeds: [embed], files: [atta] })
          mdb.findOneAndDelete({ Channel: ch.id })
        }
      })
    })
  }, 10000)

I have tried removing MongoDB parts, tried decreasing the timeout and many more... None of those helped.

Thanks in advance!

Share Improve this question asked Mar 6, 2022 at 20:24 8less8less 912 gold badges5 silver badges21 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 6

That's Discord API error, Discord receives a request from discord.js but takes too long to process so it's aborted. For more information this issue and this discord.js pull request.

Tag from official discord.js server:

AbortError: The user aborted a request.
A request took longer than the specified restRequestTimeout (15 seconds default), and was aborted to not lock up the request handler.
• This can be caused by an internal server error on Discord's side, or just a slow connection.
• In case of a slow connection, the restRequestTimeout option in ClientOptions can be increased to prevent future AbortErrors.

Check that your internet is stable, and that Discord isn't having any issues (status page). Can you visit https://discord./app in your browser? Do you have a proxy or VPN enabled?

If it's still happening, you can try the second option, which is to change the restRequestTimeout in your Client constructor.

const client = new Client({
  restRequestTimeout: 60000 // change the timeout to 1 minute
  // other options like your intents...
});
发布评论

评论列表(0)

  1. 暂无评论