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 logger crashes if config is null or undefined #94

Closed
Tracked by #103
cernadasjuan opened this issue Aug 31, 2021 · 1 comment · Fixed by #110
Closed
Tracked by #103

Error logger crashes if config is null or undefined #94

cernadasjuan opened this issue Aug 31, 2021 · 1 comment · Fixed by #110
Labels
bug Something isn't working

Comments

@cernadasjuan
Copy link

Hi! Sometimes the axios error comes with config null or undefined, and the errorLogger crashes with this exception

ERROR: Cannot destructure property `method` of 'undefined' or 'null'.

As a workaround I resolved it by adding this validation in the axios interceptor

axiosInstance.interceptors.response.use(responseLogger, (error) => {
  if (error.config && error.response) {
    return errorLogger(error)
  }
  return Promise.reject(error)
})

But I think the best solution is to add a validation in the errorLogger to prevent this type of crashes (if I catch some free time I can solve this and create the PR).

Thanks!

Note: I think is related with this issue #50

@hg-pyun
Copy link
Owner

hg-pyun commented Nov 7, 2021

Thank you for feedback. I will consider 🙇

@hg-pyun hg-pyun added the bug Something isn't working label Nov 18, 2021
@hg-pyun hg-pyun mentioned this issue Nov 29, 2021
3 tasks
tusbar added a commit to tusbar/axios-logger that referenced this issue May 3, 2022
Sometimes, axios throws an error without `error.config`, this makes sure
we don’t destructure an undefined property.

Related: axios/axios#4665
Fix hg-pyun#94
tusbar added a commit to tusbar/axios-logger that referenced this issue May 3, 2022
Sometimes, axios throws an error without `error.config`, this makes sure
we don’t destructure an undefined property.

Related: axios/axios#4665
Fix hg-pyun#94
hg-pyun added a commit that referenced this issue May 7, 2022
Sometimes, axios throws an error without `error.config`, this makes sure
we don’t destructure an undefined property.

Related: axios/axios#4665
Fix #94

Co-authored-by: Haegul Pyun <phg2491@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants