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

error: window is undefined in web worker #1145

Closed
darosh opened this issue Oct 22, 2017 · 2 comments
Closed

error: window is undefined in web worker #1145

darosh opened this issue Oct 22, 2017 · 2 comments

Comments

@darosh
Copy link

darosh commented Oct 22, 2017

Summary

After upgrade from 0.16.2 to 0.17.0 I got error window is undefined when running in web worker at line:

if (!window.XMLHttpRequest &&

Changing order of conditions typeof window !== 'undefined' and !window.XMLHttpRequest fixes the error.

Context

  • axios version: 0.17.0
  • Environment: web worker in Chrome

Notes

looking closer ar xhr.js:

  • typeof window checks could be probably replaced with typeof XMLHttpRequest and typeof btoa
  • There is new XMLHttpRequest() few lines prior !window.XMLHttpRequest check. I would expect, in case !window.XMLHttpRequest is true, new XMLHttpRequest() will throw error before the check and the check is never performed
@darosh
Copy link
Author

darosh commented Nov 9, 2017

Duplicated: #1161, Related: #1160

@nickuraltsev
Copy link
Member

Fixed via #1160

@axios axios locked and limited conversation to collaborators May 22, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants