Skip to content
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

Incorrect pagination behaviour when using the library in Electron (Specifically renderer process) #385

Closed
alaincao opened this issue Jul 8, 2019 · 15 comments

Comments

@alaincao
Copy link

alaincao commented Jul 8, 2019

Description

I am currently trying to upgrade a project from v4.2.7 (which is still working fine with this version today) to v8.0.0 (and now v9.0.0) and I have problems with pagination.
I am obviously doing something wrong, but I really can't see what ...

I noticed that the default behaviour for all api.XXX.all() with no parameter now is to returns only 20 rows. That seem to contradict what's been said in #94, first comment: "We changed it in the past to not just return 30 results since it was misleading. 30 != all lol" and the documentation in Readme.md: "For any .all() function on a resource, it will return all the items from Gitlab".

Ok, but now the strange thing is if I add { showPagination:true } in the requests, all the pagination info I get are invariably undefined.
This happens with whatever parameters I put in as parameters (page/perPage/etc.).
Also, perPage seem to be respected, but I can't get more than 100 rows returned. There seem to be a max somewhere.

Steps to reproduce / Actual behaviour
image

Expected behaviour
.all() should return all rows.

Possible fixes
Sorry, 'can't help here ...

@alaincao
Copy link
Author

alaincao commented Jul 8, 2019

Hint:
if I HTTP GET directly at /api/v4/projects/8/pipelines, I get 20 rows.
and if I do /api/v4/projects/8/pipelines?per_page=110, I get 100 rows ...

@jdalrymple
Copy link
Owner

That is very very odd. Ill give it a look soonish, hopefully its something small!

@jdalrymple jdalrymple added the Bug label Jul 8, 2019
@jdalrymple
Copy link
Owner

You used the code you specified above?

image

If you wanted all results, why specify the page? Though even if you did, the rest of the pagination information should be there. Anyways looking into it now!

@alaincao
Copy link
Author

alaincao commented Jul 9, 2019

That was just test. With or without, it did not change the undefined values.

@jdalrymple
Copy link
Owner

jdalrymple commented Jul 12, 2019

So i tested the pagination with labels and it seems to work. Ill check pipelines directly and see if anything sticks out there :(

You are awaiting for the promise to complete right?

@jdalrymple
Copy link
Owner

If you get the chance, could you check that you get the same results when getting all the labels through the labels api

@alaincao
Copy link
Author

First: sorry I could not do this earlier, but I could not afford to lose more time on this at work ...

I made some tests to isolate the problem, and when I run the code from the CLI, it works as expected.
But I tend to first develop my modules using Electron, and from there, I have the problematic results above: 'all()' returns 20 lines and 'showPagination:true' is not working.

So it seems Electron is the cause of the problem here ; I suppose this issue can be closed to open a more general one "Does not work in Electron", but I have to admit I ended up using direct HTTP calls to the API, so I'm out.

nb: I think the download of artifacts is problematic too, btw.

Big thanks for that project anyway!

@jdalrymple
Copy link
Owner

No worries! I appreciate the extra investigation :)

@jdalrymple jdalrymple changed the title Pagination seem broken Incorrect pagination behaviour when using the library in Electron Jul 15, 2019
@Helam24
Copy link

Helam24 commented Jul 15, 2019

I'm also having problems in Electron. Only getting 20 results from the .all calls for everything I'm using (Branches, MergeRequests).
Same problems with pagination info as well.

@Helam24
Copy link

Helam24 commented Jul 15, 2019

@alaincao @jdalrymple Just found that it does work properly if the api calls are done on the main electron process, and not the renderer process (how-to on this demonstrated here https://ourcodeworld.com/articles/read/537/how-to-execute-a-function-of-the-main-process-inside-the-renderer-process-in-electron-framework).

Would be nice if it worked either way though.

EDIT: this is probably a better reference https://github.com/electron/electron/blob/master/docs/api/ipc-main.md

@jdalrymple
Copy link
Owner

I wonder what would make the difference :/

@jdalrymple jdalrymple changed the title Incorrect pagination behaviour when using the library in Electron Incorrect pagination behaviour when using the library in Electron (Specifically renderer process) Jul 16, 2019
@jdalrymple
Copy link
Owner

Does the problem still occur? @Helam24

@Helam24
Copy link

Helam24 commented Apr 29, 2020

@jdalrymple I’m not sure. I’m not working on that project at the moment. I ended up moving all the relevant calls to the main process instead of the renderer process which is probably better anyway, just a little more work. Were changes made that might’ve fixed the issue?

@jdalrymple
Copy link
Owner

Nothing specific, though since then we've released a browser specific version and cleaned up alot of the logic.

@jdalrymple
Copy link
Owner

Closing for the time being. I'll reopen if the problem is encountered again!

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

No branches or pull requests

3 participants