forecast.io icon indicating copy to clipboard operation
forecast.io copied to clipboard

Stop parse er from crashing server

Open danschumann opened this issue 10 years ago • 3 comments

Cannot GET /forecast/__APIKEY__/39.63953756436671,-91.3623046875,10/22/2014T10:22:00?units=us

was my data, because my date was messed up. Only problem was that it was taking down the whole server. This should fix that.

danschumann avatar Oct 22 '14 15:10 danschumann

Hello? In the case that forecast doesn't respond, or something else happens, we should really handle a malformed call to JSON.parse, so it doesn't crash so hard. There already is an error slot in the callback. I see no reason to not accept this.

danschumann avatar Apr 06 '15 15:04 danschumann

In the meantime, I forked forecast.io-dschumann that has this commit in it.

danschumann avatar Apr 06 '15 15:04 danschumann

I get two failed tests when I run against your branch. Can you look into why this happening?

➜  fc git:(master) FORECAST_API_KEY=blablabla make test
DEBUG= ./node_modules/.bin/mocha -R spec -t 5000


  Forecast
    #get
      ✓ should return data for a latitude and longitude (60ms)
      1) should be able to specify blocks to exclude via options param
      2) should be able to specify multiple options via options param
    #getAtTime
      ✓ should return data for a latitude and longitude and time


  2 passing (166ms)
  2 failing

  1) Forecast #get should be able to specify blocks to exclude via options param:
     Uncaught AssertionError: expected { code: 400, error: 'The given location (or time) is invalid.' } to have property currently
      at Assertion.fail (/Users/matt/development/fc/node_modules/should/lib/assertion.js:196:17)
      at Assertion.prop.(anonymous function) [as property] (/Users/matt/development/fc/node_modules/should/lib/assertion.js:81:17)
      at /Users/matt/development/fc/test/index.js:45:26
      at Request._callback (/Users/matt/development/fc/index.js:63:7)
      at Request.self.callback (/Users/matt/development/fc/node_modules/request/request.js:368:22)
      at Request.emit (events.js:98:17)
      at Request.<anonymous> (/Users/matt/development/fc/node_modules/request/request.js:1219:14)
      at Request.emit (events.js:117:20)
      at IncomingMessage.<anonymous> (/Users/matt/development/fc/node_modules/request/request.js:1167:12)
      at IncomingMessage.emit (events.js:117:20)
      at _stream_readable.js:944:16
      at process._tickCallback (node.js:442:13)

  2) Forecast #get should be able to specify multiple options via options param:
     Uncaught AssertionError: expected { code: 400, error: 'The given location (or time) is invalid.' } to have property currently
      at Assertion.fail (/Users/matt/development/fc/node_modules/should/lib/assertion.js:196:17)
      at Assertion.prop.(anonymous function) [as property] (/Users/matt/development/fc/node_modules/should/lib/assertion.js:81:17)
      at /Users/matt/development/fc/test/index.js:66:26
      at Request._callback (/Users/matt/development/fc/index.js:63:7)
      at Request.self.callback (/Users/matt/development/fc/node_modules/request/request.js:368:22)
      at Request.emit (events.js:98:17)
      at Request.<anonymous> (/Users/matt/development/fc/node_modules/request/request.js:1219:14)
      at Request.emit (events.js:117:20)
      at IncomingMessage.<anonymous> (/Users/matt/development/fc/node_modules/request/request.js:1167:12)
      at IncomingMessage.emit (events.js:117:20)
      at _stream_readable.js:944:16
      at process._tickCallback (node.js:442:13)

mateodelnorte avatar Apr 06 '15 17:04 mateodelnorte