ljharb / qs

A querystring parser with nesting support

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Problem with stringify in Vite targeting ES2020

VojtechLanka opened this issue · comments

Hi,
I have run into extremely weird problem and I am not sure if this is the correct place to put it.

It seems that when I build our App using Vite 4.4.5 the qs fails to stringify nested objects with the error TypeError: Method WeakMap.prototype.set called on incompatible receiver #<N>. As far as I can tell this is caused by the line var $WeakMap = GetIntrinsic('%WeakMap%', true); called inside the sideChannel because sometimes it correctly returns the WeakMap but some other times it returns something that the debugger just show as N.

After a lot of testing I have found out that if I build the app targeting ES2017 everything works perfectly, but that is not an ideal solution.

I tried to created a minimal reproducible example but there it worked fine, which probably means that it is something in the project but I have not the slightest idea what could it be.

After some further testing it seems to be happening on specific pages which are quite compliacted and take while to load but I do not see how that should affect GetIntrinsic.

Since it's with the same node_modules, that suggests it's an issue with vite. When you're in the debugger, what is N? its typeof value, if it's a function Function.prototype.toString.call(N), etc?

I think that there is at least one joke about how if you ask someone for help with a specific problem the problem solves itself.

I think that I found the source of my issue the function N is from www.google-analytics.com/analytics.js, when I don't include the file everything works fine.

I do not understand why, and I still don't completely believe that is the problem, but I will try to figure that out next week since I am done with this one.

Thanks for your help.

Awesome, glad you figured it out (somewhat) :-)