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

Route bootstrap hangs indefinitely #608

Closed
tobiasdiez opened this issue Jan 23, 2023 · 4 comments
Closed

Route bootstrap hangs indefinitely #608

tobiasdiez opened this issue Jan 23, 2023 · 4 comments

Comments

@tobiasdiez
Copy link

Expected behavior

Starting the agent with agent.start() works.

Actual behavior

However, it hangs forever.

Failure Logs

There are no relevant logs printed. I tried to debug it and found out that execution of these promises never finishes:

await Promise.all(routes.map(route => route.bootstrap()));
. I'm not exactly sure which route is the issue, but I think it is the authentication route.

In fact, looking at

const request = superagent[method](url);
request.set('forest-secret-key', options.envSecret);
if (headers) request.set(headers);
const response = await request.send(body);
return response.body;
, there are no timeouts specified and thus I think it waits forever for a response:
https://ladjs.github.io/superagent/#timeouts

But this doesn't really explain why there is no response from the auth server in the first place...

Context

The code I'm using can be found at JabRef/JabRefOnline#1345. Just follow https://github.com/JabRef/JabRefOnline#getting-started to setup the local db, and then run yarn dev which starts the server. After that the forestadmin backend should be available at http://localhost:3000/_admin, but actually the server does not respond.

I've also tried to play around with the standalone mount: yarn node .\server\adminsimple.js. But this fails with

D:\Programming\JabRefOnline\node_modules\sequelize\lib\sequelize.js:135
      throw new Error("Dialect needs to be explicitly supplied as of v4.0.0");
            ^

Error: Dialect needs to be explicitly supplied as of v4.0.0
    at new Sequelize (D:\Programming\JabRefOnline\node_modules\sequelize\lib\sequelize.js:135:13)  
    at createEmptySequelize (D:\Programming\JabRefOnline\node_modules\@forestadmin\datasource-sql\dist\index.js:19:11)
    at buildSequelizeInstance (D:\Programming\JabRefOnline\node_modules\@forestadmin\datasource-sql\dist\index.js:29:23)
    at D:\Programming\JabRefOnline\node_modules\@forestadmin\datasource-sql\dist\index.js:38:33    
    at D:\Programming\JabRefOnline\node_modules\@forestadmin\datasource-customizer\dist\datasource-customizer.js:46:36
    at DecoratorsStack.applyQueuedCustomizations (D:\Programming\JabRefOnline\node_modules\@forestadmin\datasource-customizer\dist\decorators\decorators-stack.js:73:47)
    at DataSourceCustomizer.getDataSource (D:\Programming\JabRefOnline\node_modules\@forestadmin\datasource-customizer\dist\datasource-customizer.js:114:26)
    at Agent.start (D:\Programming\JabRefOnline\node_modules\@forestadmin\agent\dist\agent.js:56:50)
    at file:///D:/Programming/JabRefOnline/server/adminsimple.js:17:37
    at ModuleJob.run (node:internal/modules/esm/module_job:194:25)
@jeffladiray
Copy link
Member

Hey @tobiasdiez 👋

For the second part of your issue (throw new Error("Dialect needs to be explicitly supplied as of v4.0.0");), the error is raised by Sequelize. Running only yarn node .\server\adminsimple.js will not read the content of .env file by default.
So, for the mountOnStandalone version of your code, you should be able to make it run via the usage of the dotenv package. Let me know if that's the case 🙏

For the first part of the issue (About the authentication), I've forwarded this to the team in charge of this topic, that should answer you shortly 👍

@realSpok
Copy link
Contributor

Hi,

I have been looking through the server logs and couldn't find any error or timeout on the authentication routes (max is a couple seconds). Could you please retry and see if the issue persists. If so, could you please provide a timestamp of the attempt so that we can see if the error shows up in the server logs.

Thanks

@tobiasdiez
Copy link
Author

Thanks @jeffladiray and @realSpok for your help!

First of all, of course, loading the env file fixed the mountOnStandalone issue. So that's resolved. I think, I've also found a solution to my original problem. It was a combination of async promises and connection errors being hidden by nuxt. So sorry for the noise.

I think however that there should be a timeout on the superagent request. What do you think?

@jeffladiray
Copy link
Member

I guess we missed this answer :'(

i've created a ticket to add a timeout on those superagent calls as it would have been easier to understand the issue indeed.

I'm closing this, as the global issue is resolved on your end, and we'll let you know once the timeout is added on those calls.

Thanks for your feedback 🙏

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