carloscuesta / gitmoji-cli

A gitmoji interactive cli tool for using emojis on commits. 💻
https://www.npmjs.com/package/gitmoji-cli
MIT License
4.63k stars 206 forks source link

[Improvement] Increase remote fetch timeout #152

Closed cleitonper closed 5 years ago

cleitonper commented 5 years ago

Hello @carloscuesta!

After gitmoji-cli installation, when I run the gitmoji -l command the following error is returned:

ERROR: Network connection not found - ECONNABORTED
ERROR: gitmoji list not found - undefined

I changed the gitmoji.js file at line 205 to view more details about the Network connection not found error, and I discovered that this problem is related to axios timeout configuration;

# gitmoji.js

.catch((error) =>
-  this._errorMessage(`Network connection not found - ${error.code}`)
+  this._errorMessage(`Network connection not found - ${error.message}`)
)

With this change, the error was changed

# from this
ERROR: Network connection not found - ECONNABORTED
# to this
ERROR: Network connection not found - timeout of 5000ms exceeded

Increasing axios timeout in util.js file from 5000 to 30000 solves this problem.

# utils.js

const gitmojiApiClient = axios.create({
  baseURL: 'https://raw.githubusercontent.com/carloscuesta/gitmoji/master',
-  timeout: 5000,
+  timeout: 30000,
  headers: {},
  params: {}
})

Ps: A feedback message in _fetchRemoteEmojis() method should be placed, to avoid a unexpected CTRL + C during the fetch.


Maybe this issue is related to #40 and #49.

Steps to reproduce:

OS: KDE neon 5.14 gitmoji -v: 1.9.2 Node version: 10.15.0

Error Message:

gitmoji-error-1
Error with code(ECONNABORTED)
gitmoji-error-2
Error with messge(timeout of 5000ms exceeded)

Proposed fetch feedback message:

gitmoji-fetching
Hey there! We're fetching the emoji list for you.
carloscuesta commented 5 years ago

That's perfect and makes sense, feel free to send a PR! ✨