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

"Ended because API returned an empty page" with 10K messages left #471

Open
1 of 4 tasks
CSIS-James opened this issue Mar 24, 2023 · 29 comments
Open
1 of 4 tasks

"Ended because API returned an empty page" with 10K messages left #471

CSIS-James opened this issue Mar 24, 2023 · 29 comments
Labels
is-discord-breaking-change Issue caused by a breaking change in Discord's API or Client

Comments

@CSIS-James
Copy link

Undiscord Version

v5.2.0

Browser

111.0.5563.65 (Official Build) (64-bit)

Extension

TamperMonkey

Reproduction steps

  1. I initially had around 76K messages in a DM to delete
  2. I followed proper instructions, using TamperMonkey, and installed the script
  3. I ran the script, and bulk deleted around 66K messages in the span of 2-3 days
  4. This morning, I ran the script again with 10K messages remaining

Actual results

The actual result was that the window returned:

Fetching messages...
Grand total: 10565	(Messages in current page: 0	To be deleted: 0	Skipped: 0)	offset: 87
Ended because API returned an empty page.
[End condition A].	{"running":true,"delCount":0,"failCount":0,"grandTotal":10565,"offset":87,"iterations":5,"_seachResponse":{"total_results":10565,"messages":[],"analytics_id":"2c2bbd338e4da352bd5b5fce114bd10f"},"_messagesToDelete":[],"_skippedMessages":[]}

Expected results

I had expected the continuation of deletion

Bug affects

  • DMs
  • DMs (group)
  • Channels
  • Channel (NSFW)

Additional information & file uploads

None further

@kvere
Copy link

kvere commented Mar 25, 2023

getting the same issue, undiscord currently broken

@CSIS-James
Copy link
Author

CSIS-James commented Mar 25, 2023

getting the same issue, undiscord currently broken

Ah damn. I thought it was an issue on just my end. Glad to know it's not just me

This was referenced Mar 25, 2023
@victornpb
Copy link
Owner

It looks like the issue might be due to a recent Discord update. I haven't had a chance to investigate it yet, and unfortunately, I'm currently feeling sick, so I can't fix it right away. However, I'll do my best to find a solution over the weekend and let you guys know when it's resolved.

sorry and thanks for your understanding

@CSIS-James
Copy link
Author

It looks like the issue might be due to a recent Discord update. I haven't had a chance to investigate it yet, and unfortunately, I'm currently feeling sick, so I can't fix it right away. However, I'll do my best to find a solution over the weekend and let you guys know when it's resolved.

sorry and thanks for your understanding

Hey, no worries! Thanks for everything you've done; it's been really convenient. Take your time, rest up, and make sure it isn't anything bad like a fever.

Take care!

@sorryzzss
Copy link

It looks like the issue might be due to a recent Discord update. I haven't had a chance to investigate it yet, and unfortunately, I'm currently feeling sick, so I can't fix it right away. However, I'll do my best to find a solution over the weekend and let you guys know when it's resolved.

sorry and thanks for your understanding

Is there a discord server for this script?

@olstice
Copy link

olstice commented Mar 25, 2023

It looks like the issue might be due to a recent Discord update. I haven't had a chance to investigate it yet, and unfortunately, I'm currently feeling sick, so I can't fix it right away. However, I'll do my best to find a solution over the weekend and let you guys know when it's resolved.

sorry and thanks for your understanding

How will we be informed that its been resolved?

@victornpb
Copy link
Owner

victornpb commented Mar 25, 2023

expect updates on this thread

this issue will get closed, when I have a solution, and a new version will be pushed to everyone

@olstice
Copy link

olstice commented Mar 26, 2023

expect updates on this thread

this issue will get closed, when I have a solution, and a new version will be pushed to everyone

im sorry for making a duplicate! i really didnt know there was one already that you actually responded to

@victornpb victornpb added the is-discord-breaking-change Issue caused by a breaking change in Discord's API or Client label Mar 26, 2023
@PetrBlue
Copy link

Tried to use it after @hannahgrayson19 commented. Deleted 150+ messages, still going. Normally it would delete either 0 or 25 messages.

@victornpb
Copy link
Owner

victornpb commented Mar 27, 2023

Update

The search results are no longer up-to-date, this is a optimization on discord side, as it makes sense to let the database slowly reindex deleted messages instead of make it instantly reindex, it's known that removing stuff on historical databases is a resource expensive operation. Unfortunately this makes things a bit harder on Undiscord side. The good news is that I already had a plan to allow Undiscord to prefetch messages. It's a bit of a happy coincidence but I still have to finish it, so this will be a more long term solution https://github.com/victornpb/undiscord/compare/prefetch. This will be in v5.3.0.


For now, I just released v5.2.1
(Make sure to click the update button, or just click the GreasyFork button again on the home page.)

I increased the defaultSearch delay to 30s between pages.
Keep in mind this is a temporary workaround, and is not a complete fix, it still stops sometimes.

@tawtis
Copy link

tawtis commented Mar 28, 2023

Error searching messages, API responded with status 401!
{"message":"401: Unauthorized","code":0}
CoreException {}

@tawtis
Copy link

tawtis commented Mar 28, 2023

With the authorisation token filled:


Error searching messages, API responded with status 400!
	{"code":50035,"errors":{"max_id":{"_errors":[{"code":"NUMBER_TYPE_COERCE","message":"Value \"insertemailhere@mail.com\" is not snowflake."}]}},"message":"Invalid Form Body"}
CoreException	{}

@Hummel009
Copy link

Hummel009 commented Mar 28, 2023

Same problem

Error searching messages, API responded with status 400!
	{"code":50035,"errors":{"max_id":{"_errors":[{"code":"NUMBER_TYPE_COERCE","message":"Значение «myemail@gmail.com» не является snowflake."}]}},"message":"Invalid Form Body"}
CoreException	{}

@SorianoMarmol
Copy link

Same here.

I can get a 200 removing &max_id= param

hope it helps...

thanks.

image

@GGG-KILLER
Copy link

The search results are no longer up-to-date, this is a optimization on discord side, as it makes sense to let the database slowly reindex deleted messages instead of make it instantly reindex, it's known that removing stuff on historical databases is a resource expensive operation. Unfortunately this makes things a bit harder on Undiscord side.

@victornpb It'd be nice if we could use the data dump, that way it'd be able to avoid relying on the search endpoint entirely if it's available.

@VoidPr1me
Copy link

VoidPr1me commented Mar 30, 2023

HI guys, just summing up to see if my understanding is correct on this issue:

1st - v5.20 has issues with the the deleted messages lingering on for ~1min and therefore not being able to progress due to ghost "blank page" which previously held the deleted messages.

2nd - v5.21 tries to solve that by implementing a quick-fix by increasing the page search to 30s (this most likely allows the re-indexing of discords' DB)

3rd - v5.21 has authentication issue: 401, etc., downgrading to v5.20 is the only solution to keep minimal functionality.

4th - v5.30 will mostly work-out these issues but it's more or less unclear when it will be released.

is there a current "quick fix" for the issues that can allow me to progress with deleting over 50k messages on a Discord server ?

@SorianoMarmol - is this a temporary fix ? if yes, how could I (with minimal technical knowledge) implement your proposed change ? (I can get a 200 removing &max_id= param)

@SorianoMarmol
Copy link

SorianoMarmol commented Mar 30, 2023

I don't know how this works nor have I collaborated, I just know that I did a test removing that parameter and the response was 200. But as you can see in the screenshot, it can't even be interpreted, so I don't know if it's the expected response.

Regarding your question, and stressing that I don't know how this script works, maybe you can try removing the parameter from the call, I think it is this line:

['max_id', this.options.maxId ? toSnowflake(this.options.maxId) : undefined],

Alternatively (outside of undiscord) you can always take the JSON that includes the messages (and their IDs) from the interface, parse the json to get the ids, and call delete in a loop with each of the ids. With Python it should be easy. For the base you simply copy the requests (and the json) from the chrome console (for example). Last night I tried to make call by hand changing the ID of the copied request and it worked. But doing it by hand is not feasible for 50k ;)


Regarding the part of 200 removing the param, it seems that it is irrelevant, today it already responds but it continues giving an error.

@SorianoMarmol
Copy link

BTW: right now using undiscord with the token filled, the response is that indicated in the issue:

Ended because API returned an empty page.

Fetching messages... Grand total: 0 (Messages in current page: 0 To be deleted: 0 Skipped: 0) offset: 0 Delete delay: 1000ms, Search delay: 30000ms Last Ping: 236ms, Average Ping: 276ms Rate Limited: 0 times. Total time throttled: 0h 0m 0s. Estimated time remaining: 0h 0m 0s Ended because API returned an empty page. [End state] {"running":true,"delCount":0,"failCount":0,"grandTotal":0,"offset":0,"iterations":1,"_seachResponse":{"total_results":0,"messages":[],"analytics_id":"bdec65dd137eb5b2ee4756babcbb59a4"},"_messagesToDelete":[],"_skippedMessages":[]} Waiting 30.00s before next page... Ended at 30/3/2023, 19:38:10! Total time: 0h 0m 7s

@VoidPr1me
Copy link

VoidPr1me commented Mar 31, 2023

{"fileName":"eval","lineNumber":1160,"columnNumber":16,"message":"JSON.parse: unexpected character at line 1 column 1 of the JSON data"}
Could not automatically detect Authorization Token!
Please make sure Undiscord is up to date
Alternatively, you can try entering a Token manually in the "Advanced Settings" section.


It doesnt detect my auth token, not even when I manually add it :( (running 5.2.1)

@VoidPr1me VoidPr1me mentioned this issue Apr 1, 2023
4 tasks
@VoidPr1me
Copy link

Update! I tweaked around the delays in v5.20 and currently for me the following settings work:

search delay: 5000ms
delete delay: 3000ms

I probably could go lower than 3000ms but the current settings give Discord enough time to re-index the search results.
(From what I've seen it takes roughly 30 sec.)

@glassglue
Copy link

glassglue commented Apr 21, 2023

It seems there's some unknown rate-limit happening on occasion when searching for old messages -- whatever patch was implemented unfortunately isn't covering all the bases, as I found there to be relatively high degrees of variance.

I fixed this issue by editing the core to not break on the condition that an empty page is returned. My solution is available in my fork and viewable here.

It isn't a perfect solution (really just a quick hotfix so I can leave this running without error) but it does allow for autonomous deletion once again.

Edit: Successfully was able to delete ~2800 messages with this fix autonomously. There was one error I didn't handle (faulty messages continuously causing this error to propagate) that I have since fixed. Good workaround for anyone needing a quick fix!

@exile2023
Copy link

exile2023 commented Apr 23, 2023

very very cool! worked.. and i found its working too with!
5000
2600

image

seems that you need to get here values where on one slide not more than 20-24 msgs get deleted

EDIT: stopped working
but

5000
2800 is working perfectly for many K messages right now and still running

@exile2023
Copy link

It seems there's some unknown rate-limit happening on occasion when searching for old messages -- whatever patch was implemented unfortunately isn't covering all the bases, as I found there to be relatively high degrees of variance.

I fixed this issue by editing the core to not break on the condition that an empty page is returned. My solution is available in my fork and viewable here.

It isn't a perfect solution (really just a quick hotfix so I can leave this running without error) but it does allow for autonomous deletion once again.

Edit: Successfully was able to delete ~2800 messages with this fix autonomously. There was one error I didn't handle (faulty messages continuously causing this error to propagate) that I have since fixed. Good workaround for anyone needing a quick fix!

see my post, just easy working with many K messages with setting
5000
2800
slow but working proper right now

@glassglue glassglue mentioned this issue Apr 24, 2023
4 tasks
@githubUser01946
Copy link

It seems there's some unknown rate-limit happening on occasion when searching for old messages -- whatever patch was implemented unfortunately isn't covering all the bases, as I found there to be relatively high degrees of variance.

I fixed this issue by editing the core to not break on the condition that an empty page is returned. My solution is available in my fork and viewable here.

It isn't a perfect solution (really just a quick hotfix so I can leave this running without error) but it does allow for autonomous deletion once again.

Edit: Successfully was able to delete ~2800 messages with this fix autonomously. There was one error I didn't handle (faulty messages continuously causing this error to propagate) that I have since fixed. Good workaround for anyone needing a quick fix!

Not sure how to use your fork with tampermonkey

@ttuleyb
Copy link

ttuleyb commented Jun 21, 2023

Hello! I've added a fix that bypasses this issue by skipping any empty pages. I have not checked this thoroughly for any bugs but it seems to be deleting messages just fine, the only change I made was to skip a maximum of 3 empty pages every time an empty page is found.

https://pastebin.com/9Yq3r9Rw

Make sure to Diffcheck it with the original before loading the script so you can see and approve my changes.

@JayBoom
Copy link

JayBoom commented Aug 1, 2023

Hello! I've added a fix that bypasses this issue by skipping any empty pages. I have not checked this thoroughly for any bugs but it seems to be deleting messages just fine, the only change I made was to skip a maximum of 3 empty pages every time an empty page is found.

https://pastebin.com/9Yq3r9Rw

Make sure to Diffcheck it with the original before loading the script so you can see and approve my changes.

@victornpb Can you confirm if this works and push it into the next update?

@sapphonie
Copy link

sapphonie commented Aug 5, 2023

Hello! I've added a fix that bypasses this issue by skipping any empty pages. I have not checked this thoroughly for any bugs but it seems to be deleting messages just fine, the only change I made was to skip a maximum of 3 empty pages every time an empty page is found.

https://pastebin.com/9Yq3r9Rw

Make sure to Diffcheck it with the original before loading the script so you can see and approve my changes.

...could you open a PR?

@glassglue
Copy link

It seems there's some unknown rate-limit happening on occasion when searching for old messages -- whatever patch was implemented unfortunately isn't covering all the bases, as I found there to be relatively high degrees of variance.
I fixed this issue by editing the core to not break on the condition that an empty page is returned. My solution is available in my fork and viewable here.
It isn't a perfect solution (really just a quick hotfix so I can leave this running without error) but it does allow for autonomous deletion once again.
Edit: Successfully was able to delete ~2800 messages with this fix autonomously. There was one error I didn't handle (faulty messages continuously causing this error to propagate) that I have since fixed. Good workaround for anyone needing a quick fix!

Not sure how to use your fork with tampermonkey

You can find the compiled script here. The source code is also provided.

Hello! I've added a fix that bypasses this issue by skipping any empty pages. I have not checked this thoroughly for any bugs but it seems to be deleting messages just fine, the only change I made was to skip a maximum of 3 empty pages every time an empty page is found.
https://pastebin.com/9Yq3r9Rw
Make sure to Diffcheck it with the original before loading the script so you can see and approve my changes.

...could you open a PR?

Do note that this page-blank fix opens the door to a myriad of issues. I knocked out quite a few of them in my fork, but there is one remaining bug that I did not test for accuracy. I would not recommend PRing just a page-blank fix as it will (probably) create more problems than it's worth.

I can review potential bugs a bit later and potentially PR that when I am reasonably confident no further bugs will propagate.

@etozheDT
Copy link

Bug still reproducing
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
is-discord-breaking-change Issue caused by a breaking change in Discord's API or Client
Projects
None yet
Development

No branches or pull requests