Skip to content

requesting larger chunks of json is not working… #413

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
kevinfoerster opened this issue Aug 1, 2014 · 14 comments
Closed

requesting larger chunks of json is not working… #413

kevinfoerster opened this issue Aug 1, 2014 · 14 comments

Comments

@kevinfoerster
Copy link

hi there,

i just tried to request some records from mongodb and saw some strange behavior, in my case I requested all records of a given table, in this case 429 records, after receiving them successfully I used res.json(200, videos) to output that object as a json.

it seems like my browser does not receive the full 429 records (look like twice the same output), therefor it is not valid json and cant be used for anything. while investigating this issue, i found out that limiting the number of results by using videos = videos.slice(0, 43); before sending the json solves that issue but limits the output.

including one more item of the videos array will break the json again… there is nothing wrong with next entry as videos = videos.slice(20, 60); is also working as well, displaying 45 elements will break it again.

i tried to output the same data using an older version of the generator (1.4.3) without any problems, all 429 records show as expected.

intresting tidbit: chrome, firefox and safari seem to render the json twice which makes it invalid,a simple curl http://localhost:9000/api/videos | subl does not show the json duplicated. I tried a second computer to be sure that its not my browser plugins messing with me.

btw… how can i figure out which version generator-angular-fullstack was used to create a project and is there a way to update an existing project?

@kevinfoerster
Copy link
Author

seems to be duplicate of #380

@DaftMonk
Copy link
Member

DaftMonk commented Aug 2, 2014

Hmm actually we did save the version number with the gruntfile pre 2.0, but with the refactoring that must have gotten removed. We should probably add that to the yo.rc.json file.

You can update a 2.0+ version just by rerunning the generator in the project, it will ask you if you want to replace files that were updated. Make sure your project is backed up or commited before doing this. You can do a diff afterwords with git and decide what changes you want to keep.

So the strange thing about this bug is that it only seems to effect the way the data is rendered in the browser. I tried running a test to see if the response was actually duplicated and it seemed to work fine to me. Do you have some example client side javascript thats hitting the endpoint where you're seeing this become a real issue?

@joelkek
Copy link

joelkek commented Nov 20, 2014

@DaftMonk, I see this bug on Chrome, and it doesn't show on Postman for me either, but I think this might just be Postman only displaying the first complete JSON object?

My Angular code is failing because of this bug. I just have a vanilla $http.get call.

 $http.get('/api/thing').
  success(function(data) {
    // fails even when this is empty
})

The entire Angular app fails even when the success function is empty, because Angular is crashing when it tries to parse variable "data" as a JSON.

@Awk34
Copy link
Member

Awk34 commented Nov 20, 2014

@joelkek Do you think your issue is also caused by the size of your JSON object? How big is it?

@benjipott
Copy link

  • 1 for me. sometimes json is duplicated

@mathieuartu
Copy link

My issue (#744) is about the same problem...

@mathieuartu
Copy link

Ok, I closed my issue so I'm going to repost this here :

Hello,

I've been experiencing problems with json and generator-angular-fullstack recently.
Try it for yourself : just add a large amount of "things" into the seed.js file via the Thing.create({...}) function, then try to display it via http://localhost/api/things.

You'll notice that at some point there's the end of the JSON "]" and then its starts again right away "[".
I've tested it in 3 different environments and still can reproduce the bug.

I don't think the amount of data is too large since it should be a able to display hundreds of things and not be limited to somewhat approximately 90 items.

Do you guys know about this, and is there a workaround ? Thanks !

@kingcody
Copy link
Member

I can confirm the issue as well. If anyone would like to follow along or take a stab: expressjs/compression#20

@kingcody
Copy link
Member

Hmm, it would seem that [email protected] was actually causing the issue; but only when used with expressjs/compression.

By upgrading (npm install --save-dev [email protected]) to the newest version the issue was resolved in my tests.

@kevinfoerster, @benjipott, @mathieuartu, @Awk34 can you all confirm this?

@Awk34
Copy link
Member

Awk34 commented Jul 15, 2015

So this issue was only happening in dev?

@kingcody
Copy link
Member

It would seem so. Were you able to confirm the resolution?

@Awk34
Copy link
Member

Awk34 commented Jul 15, 2015

nah I'm still at work, will take a look when I get home

@dougwilson
Copy link

As additional information, someone needs to make a PR to change https://github.com/DaftMonk/generator-angular-fullstack/blob/master/app/templates/_package.json#L75 to require some version of connect-livereload >= 0.5.0; before 0.5.0, it does not play nice with any modules that also overwrite res.write, like express-session and compression, to name just a few popular ones. 0.5.0 was released in Oct 2014.

kingcody added a commit to kingcody/generator-angular-fullstack that referenced this issue Jul 16, 2015
@kingcody
Copy link
Member

closed by #1065

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants