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

URLSearchParams Error #821

Closed
karanmartian opened this issue Aug 6, 2020 · 13 comments · Fixed by #822
Closed

URLSearchParams Error #821

karanmartian opened this issue Aug 6, 2020 · 13 comments · Fixed by #822

Comments

@karanmartian
Copy link

Hey Guys, please help after upgrading to latest version of whatwg-fetch v3.3.1

I am seeing this error

TypeError: Cannot use 'in' operator to search for 'URLSearchParams' in false
at /home/karan/Desktop/repos/idwapp/node_modules/whatwg-fetch/dist/fetch.umd.js:10:37
at /home/karan/Desktop/repos/idwapp/node_modules/whatwg-fetch/dist/fetch.umd.js:2:66
at Object. (/home/karan/Desktop/repos/idwapp/node_modules/whatwg-fetch/dist/fetch.umd.js:5:2)
at Module._compile (internal/modules/cjs/loader.js:1158:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10)
at Module.load (internal/modules/cjs/loader.js:1002:32)
at Function.Module._load (internal/modules/cjs/loader.js:901:14)
at Module.require (internal/modules/cjs/loader.js:1044:19)
at require (internal/modules/cjs/helpers.js:77:18)
at Object. (/home/karan/Desktop/repos/idwapp/functions/index.js:1:143379)
error: Forever detected script exited with code: 1
error: Script restart attempt #9
/home/karan/Desktop/repos/idwapp/node_modules/whatwg-fetch/dist/fetch.umd.js:10
searchParams: 'URLSearchParams' in global,

@JakeChampion
Copy link
Owner

@karanmartian Can you run this on the page and tell us what it returns please?
(typeof self !== 'undefined' && self) || (typeof global !== 'undefined' && global)

@karanmartian
Copy link
Author

@JakeChampion its returning false, in fetch.umd.js

var global = (typeof self !== 'undefined' && self) || (typeof global !== 'undefined' && global);

console.log(global); --> false

var support = {
searchParams: 'URLSearchParams' in global,
iterable: 'Symbol' in global && 'iterator' in Symbol,
......

@JakeChampion
Copy link
Owner

Is that from the self or from the global?

@karanmartian
Copy link
Author

global

@JakeChampion
Copy link
Owner

Oh that is interesting, is this error from a NodeJS application?
Do you know what is modifying the global variable named global?

@karanmartian
Copy link
Author

React JS and Node JS yes

I have no idea what is modifying it. Can another library influence it?

@JakeChampion
Copy link
Owner

Yes, it is a global variable which is meant to point to the global object.

We can add a work around in this codebase but really, anything which is making the global variable global not point to the global object will be causing issues in lots of packages.

@karanmartian
Copy link
Author

@JakeChampion could you please add the workaround? I dont seem to have another option at this time and I have been stuck at v2.0.4 for a long time now.

@JakeChampion
Copy link
Owner

This should fix it for you if you are on NodeJS 12 or higher -- #822

@karanmartian
Copy link
Author

@JakeChampion Tysm will there be a new release with this fix?

@JakeChampion
Copy link
Owner

Sure thing, in the meantime you can find the culprit modifying the global self variable with this code.
If you include this in your entry file before any other code and then open the developer tools you will find the piece of code which is modifying the self variable.

Object.defineProperty(window, 'self', {
  configurable: true,
  enumerable: false,
  set: function(value) {
    // The delete command removes the setter.
    delete window.self;
    window.self = value;
	debugger;
    console.log("self global variable was modified!");
  }
});

@JakeChampion
Copy link
Owner

published in 3.4.0 👍

@karanmartian
Copy link
Author

tysm @JakeChampion really appreciate it a lot☺️

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 4, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants