sseemayer / NEOW

Node.js Eve Online API Wrapper (with Promises)
MIT License
19 stars 6 forks source link

char:CharacterSheet fails with RangeError. #2

Closed Lugghawk closed 10 years ago

Lugghawk commented 10 years ago
function updatecharsheet(character){
  var neow = require('neow');
  var client = new neow.Client({
    keyID: character.api.keyID,
    vCode: character.api.vCode,
    characterID: character.charId
  })
  client.fetch('char:CharacterSheet').then(function(result){
    console.log(result);
  })
}

Running this code on my character gives me the following error:

RangeError: Maximum call stack size exceeded

I've read around and it sounds that it is because it is attempting to handle a large amount of data that this happens. The CharacterSheet return includes both employment history and skills on the character, and for an older character this can end up being pretty large.

sseemayer commented 10 years ago

I'm a pretty young player myself so I'm not sure how i can best reproduce this. Would you be willing to send me an XML dump of your character sheet?

Lugghawk commented 10 years ago

Sure. I don't think I can attach files here, so do you have an email I can send it to?

sseemayer commented 10 years ago

[redacted] - Thanks for your help, I'll try to get to it on the weekend!

Lugghawk commented 10 years ago

Sent.

On Thu, Feb 6, 2014 at 6:15 PM, Stefan Seemayer notifications@github.comwrote:

stefan@seemayer.de - Thanks for your help, I'll try to get to it on the weekend!

Reply to this email directly or view it on GitHubhttps://github.com/sseemayer/NEOW/issues/2#issuecomment-34386048 .

Thanks, Dave Lugg

Restate my assumptions: One, Mathematics is the language of nature. Two, Everything around us can be represented and understood through numbers. Three: If you graph the numbers of any system, patterns emerge. Therefore, there are patterns everywhere in nature.

sseemayer commented 10 years ago

Thanks, got it. Will delete my email address above in the hopes of avoiding those web crawlers.

Lugghawk commented 10 years ago

Good idea.

On Thu, Feb 6, 2014 at 6:17 PM, Stefan Seemayer notifications@github.comwrote:

Thanks, got it. Will delete my email address above in the hopes of avoiding those web crawlers.

Reply to this email directly or view it on GitHubhttps://github.com/sseemayer/NEOW/issues/2#issuecomment-34386231 .

Thanks, Dave Lugg

Restate my assumptions: One, Mathematics is the language of nature. Two, Everything around us can be represented and understood through numbers. Three: If you graph the numbers of any system, patterns emerge. Therefore, there are patterns everywhere in nature.

Lugghawk commented 10 years ago

So I'm not entirely convinced this was an error in your api anymore. I set up a pure route without any other logic, and did an XMLHttpRequest to the characterinfo page and it worked without a hitch. So the amount of data might not be the problem.

However, trying to a call with neow from a pure route no longer gives me the stack size error, but rather this:

                    throw e;
                          ^
Error: Unquoted attribute value
Line: 27
Column: 65
Char: 1

I found a younger character that has less information spewed from CharacterInfo to test with also, this is the xml that I get back from him:

<?xml version='1.0' encoding='UTF-8'?>
<eveapi version="2">
  <currentTime>2014-02-07 04:54:13</currentTime>
  <result>
    <characterID>93594694</characterID>
    <characterName>Drogai Khalur</characterName>
    <race>Minmatar</race>
    <bloodline>Sebiestor</bloodline>
    <accountBalance>812500.00</accountBalance>
    <skillPoints>5842243</skillPoints>
    <shipName>Drogai Khalur's Reaper</shipName>
    <shipTypeID>588</shipTypeID>
    <shipTypeName>Reaper</shipTypeName>
    <corporationID>579016209</corporationID>
    <corporation>Spawn More Overlords</corporation>
    <corporationDate>2013-07-12 05:02:00</corporationDate>
    <allianceID>99003050</allianceID>
    <alliance>Contrapuntal Alliance</alliance>
    <allianceDate>2013-07-16 04:17:00</allianceDate>
    <lastKnownLocation>Aphend</lastKnownLocation>
    <securityStatus>0</securityStatus>
    <rowset name="employmentHistory" key="recordID" columns="recordID,corporationID,startDate">
      <row recordID="26816995" corporationID="579016209" startDate="2013-07-12 05:02:00" />
      <row recordID="26816948" corporationID="1000170" startDate="2013-07-12 04:58:00" />
    </rowset>
  </result>
  <cachedUntil>2014-02-07 05:41:15</cachedUntil>
</eveapi>
sseemayer commented 10 years ago

I've had some time to debug and it turns out that NEOW quietly ignored the error resulting from specifying an incorrect request URL. The real API endpoint is char:CharacterSheet, not account:CharacterSheet. The EVE API Server returned 404 but NEOW still tried to parse the error page, resulting in the error. I've added a check for the HTTP status code when the XHR returns so that the promise will be rejected with a meaningful error message and published a version 0.0.3 containing the fix.

sseemayer commented 10 years ago

I didn't test on your big character sheet so I will leave this open as there might be a second bug hiding here. Loading it as an XML seems to work fine, but please try requesting your big character sheet again and let me know if you are getting any further.

Lugghawk commented 10 years ago

My apologies the code I pasted was incorrect. I was using eve/CharacterInfo and char/CharacterSheet. I must have been playing around with it and posted the wrong stuff.

sseemayer commented 10 years ago

No problem, NEOW now has an additional important bit of error handling that wasn't there before :) Can you retrieve data for your older character, too?

Lugghawk commented 10 years ago

Ok so I tried the following with both a large and small character:

var neow = require('neow');
  var client = new neow.Client({
    keyID: apiclient.keyID,
    vCode: apiclient.vCode,
    characterID: apiclient.charId
  });
  client.fetch('char:CharacterSheet').then(function(result){
    console.log(result);
  }).done()

And I get the following issue:

                    throw e;
                          ^
TypeError: Cannot set property 'currentTime' of undefined
    at SAXStream.<anonymous> (..\node_modules\neow\lib\parser.js:87:23)
    at SAXStream.EventEmitter.emit (events.js:92:17)
    at Object.SAXStream._parser.onend (..\node_modules\neow\node_modules\sax\lib\sax.js:184:8)
    at emit (..\node_modules\neow\node_modules\sax\lib\sax.js:615:33)
    at end (..\node_modules\neow\node_modules\sax\lib\sax.js:654:3)
    at Object.SAXParser.end (..\node_modules\neow\node_modules\sax\lib\sax.js:149:24)
    at SAXStream.end (..\node_modules\neow\node_modules\sax\lib\sax.js:234:16)
    at root.parse (..\node_modules\neow\lib\parser.js:95:14)
    at _fulfilled (..\node_modules\neow\node_modules\q-io\node_modules\q\q.js:798:54)
    at self.promiseDispatch.done (..\node_modules\neow\node_modules\q-io\node_modules\q\q.js:827:30)

The data returned from char:CharacterSheet is the same as what I emailed you. Sorry for all the confusion here.

In any case, the RangeError must be something in my code, since having a route which only looks up characters seems to be happy enough. I'm very new to async javascript stuff so I must be missing something which is causing it to recurse indefinitely.