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

API requests with files error on retry with aiohttp 3.7 #6531

Closed
3 tasks done
Jackenmen opened this issue Mar 14, 2021 · 0 comments
Closed
3 tasks done

API requests with files error on retry with aiohttp 3.7 #6531

Jackenmen opened this issue Mar 14, 2021 · 0 comments
Labels
bug This is a bug with the library.

Comments

@Jackenmen
Copy link
Contributor

Summary

If API request with a file (i.e. sending a message with a file) fails and d.py needs to try the request, it errors out

Reproduction Steps

Reliable repro is a bit hard to make as this only happens if d.py needs to retry the API request.
The code with which this can happen can be something like this:

from io import BytesIO
fp = BytesIO(b"foobar")
await ctx.send("message", discord.File(fp, "testfile.txt"))

Expected Results

No error

Actual Results

Traceback:

File "python3.8/site-packages/discord/abc.py", line 915, in send
  data = await state.http.send_files(channel.id, files=[file], allowed_mentions=allowed_mentions,
File "python3.8/site-packages/discord/http.py", line 185, in request
  async with self.__session.request(method, url, **kwargs) as r:
File "python3.8/site-packages/aiohttp/client.py", line 1117, in __aenter__
  self._resp = await self._coro
File "python3.8/site-packages/aiohttp/client.py", line 492, in _request
  req = self._request_class(
File "python3.8/site-packages/aiohttp/client_reqrep.py", line 313, in __init__
  self.update_body_from_data(data)
File "python3.8/site-packages/aiohttp/client_reqrep.py", line 507, in update_body_from_data
  body = body()
File "python3.8/site-packages/aiohttp/formdata.py", line 168, in __call__
  return self._gen_form_data()
File "python3.8/site-packages/aiohttp/formdata.py", line 132, in _gen_form_data
  raise RuntimeError("Form data has been processed already")
RuntimeError: Form data has been processed already

Intents

discord.Intents.all()

System Information

  • Python v3.8.8-final
  • discord.py v1.6.0-final
  • aiohttp v3.7.3
  • system info: Windows 10 10.0.19041

Checklist

  • I have searched the open issues for duplicates.
  • I have shown the entire traceback, if possible.
  • I have removed my token from display, if visible.

This happens on aiohttp 3.7 as the FormData object has been changed so that it only can be used once.

Related commit and issues:
aio-libs/aiohttp@d931f10
aio-libs/aiohttp#4351
aio-libs/aiohttp#4345

I know you're already aware of this issue but I figured it might be worth making a tracking issue for this so that it doesn't get lost.

@Jackenmen Jackenmen added the bug This is a bug with the library. label Mar 14, 2021
@Rapptz Rapptz closed this as completed in 1c8d1b0 Mar 24, 2021
yagomichalak pushed a commit to yagomichalak/discord.py that referenced this issue May 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This is a bug with the library.
Projects
None yet
Development

No branches or pull requests

1 participant