larsgw / citation.js

Citation.js converts formats like BibTeX, Wikidata JSON and ContentMine JSON to CSL-JSON to convert to other formats like APA, Vancouver and back to BibTeX.
https://citation.js.org/
MIT License
222 stars 30 forks source link

deprecation warning if Wikidata server is down #175

Closed egonw closed 5 years ago

egonw commented 5 years ago

It's not really a bug, as I do expect the code to fail if the upstream server is down, but there is at the end a note of deprecated functionality:

(node:16855) UnhandledPromiseRejectionWarning: FetchError: request to https://www.wikidata.org/w/api.php?action=wbgetentities&ids=Q3186908&format=json&languages=en&props=labels failed, reason: connect ETIMEDOUT 91.198.174.192:443
    at ClientRequest.<anonymous> (/home/egonw/var/Projects/hub/cdkbook/node_modules/node-fetch/index.js:133:11)
    at ClientRequest.emit (events.js:189:13)
    at TLSSocket.socketErrorListener (_http_client.js:392:9)
    at TLSSocket.emit (events.js:189:13)
    at emitErrorNT (internal/streams/destroy.js:82:8)
    at emitErrorAndCloseNT (internal/streams/destroy.js:50:3)
    at process._tickCallback (internal/process/next_tick.js:63:19)
(node:16855) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:16855) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
larsgw commented 5 years ago

If there are contributors, that code right there:

  try {
    return fetch(url, reqOpts).then(response => response.text())
  } catch (e) {
    logger.error('[set]', `File '${url}' could not be fetched:`, e.message)
    return '[]'
  }
larsgw commented 5 years ago

Fixed in https://github.com/citation-js/citation-js/commit/f02542601f034ea086d36759b77b642cb866e792