Localhost environment requests never complete and are always (pending)

Expected behavior

Previously all of my local data would load normally and I could use forest as expected.

Actual behavior

Now the table view just shows the loading column gif. Upon inspecting the network requests it shows (pending) and never resolves.

I’m able to successfully connect on production, so something is wrong with local. Below is a screenshot of the network requests just hanging.

In the logs I can see OPTIONS requests being sent and returning 200, but I don’t see any requests for the actual GET.

Failure Logs

Unfortunately, the logs seem to be empty.

Context

Please provide any relevant information about your setup.

  • Package Version: “forest-express-sequelize”: “3.3.5”,
  • Express Version: “express”: “~4.13.4”,
  • Sequelize Version: “sequelize”: “^5.18.4”,
  • Database Dialect: postgres
  • Database Version: 12

Hello @carbon-matt and welcome to the Forest Admin support!

When did you start notifying this issue? Is it recent?
Are the dependencies on your local project the same as in production?

Your forest-express-sequelize version seems a quite old. The last one is 6.3.13.

You can find documentation on how to update it:
v3->v4
v4->v5
v5->v6

Let me know if it helps :grinning:

Thanks for the reply @Guillaume_Cisco!

I was last able to successfully work with the project in August this year. Unfortunately, I then hadn’t done any work with it since then. So there’s about a 2 month period where things somehow stopped working.

I just tried upgrading to v4 and then subsequently to v5. The issue still occurs for both versions. So it seems like the issue isn’t necessarily forest admin itself but some way in which the request to express is not completing or that request to the database is not completing. Is there some way for me to inspect requests being passed?

You’re welcome @carbon-matt :smiley:
As I can see, it seems that the pending requests are ones calling your project.
Did you override the /serviceGroups or /serviceGroups/count routes?
If yes, you could investigate from here, to see if it is correctly reached or not.
Maybe a middleware is breaking?

Let me know,

@Guillaume_Cisco I’ve tried removing as much middleware as possible and the same issue occurs on the network requests. We also have other developers that seem to have no issue with our middleware configuration. We’ve compared configurations and can’t seem to find any discrepancies.

Looking at setup steps here: https://docs.forestadmin.com/documentation/how-tos/databases/plug-multiple-sql-databases#1-update-the-models-index-js-file

I have the databaseOptions.logging configured but see no database logs from sequelize.

I’ve also tried logging by following these sequelize connection test calls: https://sequelize.org/master/manual/getting-started.html#testing-the-connection

This is in my index.js:

let sequelize = new Sequelize(process.env.DATABASE_URL, databaseOptions);

sequelize.authenticate()
    .then(() => {
        console.log('Connection has been established successfully.');
}).catch((error) => {
        console.error('Unable to connect to the database:', error);
});

But I see none of these messages in my console output.

So it would seem like there’s some database connection issue but there is no record of why that’s the case. Again I’ve compared with other developers that this works for and our connection strings for DATABASE_URL are the same.

Any other ideas on how I can pin this down?

Hey @carbon-matt,

Do you have any CORS issue on your front in the console ?
Could you share the server logs you get when starting your server :thinking: ?

@vince

Sure thing! Here’s my console output:

$ NODE_ENV=development nodemon ./bin/www --exec babel-node
[nodemon] 1.19.4
[nodemon] to restart at any time, enter `rs`
[nodemon] watching dir(s): *.*
[nodemon] watching extensions: js,mjs,json
[nodemon] starting `babel-node ./bin/www.js`
(node:42862) Warning: Accessing non-existent property 'padLevels' of module exports inside circular dependency
(Use `node --trace-warnings ...` to show where the warning was created)
🌳  Open your admin UI: http://app.forestadmin.com 🌳
express deprecated res.send(status): Use res.sendStatus(status) instead node_modules/express-cors/index.js:95:45
OPTIONS /forest/sessions-google 200 3.227 ms - 2
POST /forest/sessions-google 200 1357.236 ms - 420
OPTIONS /forest/stats/patients 200 0.622 ms - 2
OPTIONS /forest/stats/users 200 0.481 ms - 2
OPTIONS /forest/choices?fields%5Bchoices%5D=createdAt%2Cid%2Clabel%2CsortIndex%2Cvalue&filterType=and&page%5Bnumber%5D=1&page%5Bsize%5D=15&searchExtended=0&sort=-id&timezone=America%2FDetroit 200 0.507 ms - 2
OPTIONS /forest/choices/count?fields%5Bchoices%5D=createdAt%2Cid%2Clabel%2CsortIndex%2Cvalue&filterType=and&searchExtended=0&timezone=America%2FDetroit 200 0.478 ms - 2

I do have cors configured in app.js and just tried editing it to allow *:

app.use(cors({
  // allowedOrigins: ['*.forestadmin.com'], // regular policy
  allowedOrigins: ['*'], // edited to test this
  headers: ['Authorization', 'X-Requested-With', 'Content-Type']
}));

However I see the same results. I even tried commenting that block out completely. There is nothing in the logs and the network requests never complete:

[nodemon] restarting due to changes...
[nodemon] starting `babel-node ./bin/www.js`
(node:42928) Warning: Accessing non-existent property 'padLevels' of module exports inside circular dependency
(Use `node --trace-warnings ...` to show where the warning was created)
🌳  Open your admin UI: http://app.forestadmin.com 🌳
OPTIONS /forest/choices?fields%5Bchoices%5D=createdAt%2Cid%2Clabel%2CsortIndex%2Cvalue&filterType=and&page%5Bnumber%5D=1&page%5Bsize%5D=15&searchExtended=0&sort=-id&timezone=America%2FDetroit 204 5.500 ms - 0
OPTIONS /forest/choices/count?fields%5Bchoices%5D=createdAt%2Cid%2Clabel%2CsortIndex%2Cvalue&filterType=and&searchExtended=0&timezone=America%2FDetroit 204 0.478 ms - 0

In fact I only see the cancelled GET when I navigate to another table:

GET /forest/choices?fields%5Bchoices%5D=createdAt%2Cid%2Clabel%2CsortIndex%2Cvalue&filterType=and&page%5Bnumber%5D=1&page%5Bsize%5D=15&searchExtended=0&sort=-id&timezone=America%2FDetroit - - ms - -
GET /forest/choices/count?fields%5Bchoices%5D=createdAt%2Cid%2Clabel%2CsortIndex%2Cvalue&filterType=and&searchExtended=0&timezone=America%2FDetroit - - ms - -

Okey and on the browser side, could you share your logs :thinking: ?

It might be a firewall issue

Yep, the console is pretty uneventful:

And here’s the network waterfall where you can see the (pending).

When you say firewall, where do you suspect it may be blocked? I’ve disabled my local adblocker for all of these screenshots and my router has no firewall configured besides the default SPI Firewall which I haven’t changed since this was previously working.

Hello @carbon-matt ! I’m jumping into this conversation to try to help you out with your problem.

From what I can see, you’re not starting your server in a “standard” way, would you mind sharing with us the content of your ./bin/www.js file ? I would like to be sure everything is set up correctly ! :slightly_smiling_face:

Hello @carbon-matt We have investigated on this, it looks like the culprit is the pg dependency, may I ask you to upgrade it to version 8.2.2 ?

Keep me in touch :raised_hand:

Awaiting your answer,

Steve.

@remi apologies on the delay; I checked in that file and it simply adds some listeners by doing the following:

var server = http.createServer(app);

server.listen(port);
server.on('error', onError);
server.on('listening', onListening);

@Steve_Bunlon this solved it! I upgraded and everything is working as expected!

Thanks everyone for helping and looking into this with me!

2 Likes