TIL:

console.log(JSON.stringify(new Set(["bla", "foo"])))

prints

{}

which does not mean that the set was empty.

ChatGPT found it after three rounds of finding errors that were no errors at all and

> I apologize for the confusion. Upon further inspection, I see another issue in the code.

Reply to this note

Please Login to reply.

Discussion

Array.from(new Set()) will fix it

The fix was not the hard part. Just not using JSON.stringify() was good enough. The problem was that I had empty sets for other reasons so I tested just those 20 LOC with a console.log in the end and I was scratching my head for half an hour why the set was empty all the time.