mapbox / mapbox/mapbox-sdk-js

module.exports.RequestError: getaddrinfo ENOTFOUND api.mapbox.com api.mapbox.com:443

Open
#325 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
768
Forks
191
PR merge metrics
No merged PRs in 30d

Description

Hi,

I am testing the mapbox API for production deployment and I have run into an interesting error.

**module.exports.RequestError: getaddrinfo ENOTFOUND api.mapbox.com api.mapbox.com:443**

when simulating a network outage the following error is emitted from got module:

**at ClientRequest.req.once.err (/opt/application/node/node_modules/got/index.js:182:22)**

I believe the issue is that the error is not caught when creating a new stream here:

https://github.com/mapbox/mapbox-sdk-js/blob/c0ae1604f9f05a91335c70a8535597e1517c1acb/lib/node/node-layer.js#L67

I might be mistaken but shouldn't this Promise have something like the following:

gotStream.on('error', function(error) {
...
...
reject(error)
});

or something like that?

Currently the emitted error is killing the node application.

for reference https://nodejs.org/dist/latest-v10.x/docs/api/events.html#events_error_events

Sample code to reproduce: using the turf.js and mapbox

import * as mbxClient from '@mapbox/mapbox-sdk'
import * as mbxTilequery from '@mapbox/mapbox-sdk/services/tilequery'

var baseClient = mbxClient({ MBX_TOKEN})
var tilequeryClient = mbxTilequery(baseClient)

public getTile = (feature) => {

const requestTile = this.tilequeryClient.listFeatures({
mapIds: ['mapbox.mapbox-terrain-v2','mapbox.mapbox-streets-v8'],
coordinates: feature.geometry.coordinates
})

return requestTile.send()
.then(response => {
const features = response.body;
return features;
},error => {
throw error
})
}

var extent = [-70.823364, -33.553984, -70.473175, -33.302986];
var cellSide = 3;
var options = {units: 'kilometers'};

var mapPointGrid = turf.pointGrid(extent, cellSide, options);
var featureCollections = await Promise.all(mapPointGrid.features.map(getTile))
.then(results => {return results})
.catch(error => {throw new ClientDependencyError(error)})

thanks!

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in lib/node/node-layer.js at the linked line where the got request stream is created, and reproduce the failure using the provided tilequery sample with a simulated network outage. Verify that the network error is delivered through the returned Promise and can reach the sample's catch handler instead of terminating the Node application.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.