App on Heroku crashed after update from v.3.3.4 to v.3.4.0

Hi Guys,
I’ve just upgraded my Strapi project from v3.3.4 to v3.4. It’s going fine on my localhost, but the app crashed on Heroku. Where could the problem be? :thinking:
I have never seen the following error message:

Thanks in advance. :roll_eyes:

P.S.: Does it have anything to do with the database? :snail:

Hi @mingxi , try to delete .cache folder, build the project again “yarn build” and restart your app and see if that helps.

@lexcode Hello, Thanks for the quick reply! :+1:
How do I delete “.cache” folder on Heroku? “.cache” folder is supposed to be recreated every time the project is deploied again. My app runs normally on localhost. This problem only exists on Heroku.
But on Heroku I have a second Strapi project that doesn’t have this problem. I’m doing a database comparison. :thinking_face:

Solution found! :relaxed: @lexcode hank you anyway!
Please see the link below:

Hi @mingxi
The solution you are pointing to solves it for a sql db as far as I can see. I’m using mongodb and get a similar problem.

The code was tested on localhost and works just fine connecting to the same db. But on heroku I get this error:

2021-01-11T19:37:55.000000+00:00 app[api]: Build succeeded
2021-01-11T19:38:00.498308+00:00 app[web.1]: [2021-01-11T19:38:00.497Z] error Bootstrap function in plugin “users-permissions” failed
2021-01-11T19:38:00.500435+00:00 app[web.1]: [2021-01-11T19:38:00.500Z] error TypeError: Cannot read property ‘_id’ of undefined
2021-01-11T19:38:00.500437+00:00 app[web.1]: at /app/node_modules/strapi-plugin-users-permissions/services/UsersPermissions.js:263:59
2021-01-11T19:38:00.500459+00:00 app[web.1]: at Array.map ()
2021-01-11T19:38:00.500461+00:00 app[web.1]: at Object.updatePermissions (/app/node_modules/strapi-plugin-users-permissions/services/UsersPermissions.js:262:46)
2021-01-11T19:38:00.500463+00:00 app[web.1]: at processTicksAndRejections (node:internal/process/task_queues:93:5)
2021-01-11T19:38:00.500464+00:00 app[web.1]: at async module.exports (/app/node_modules/strapi-plugin-users-permissions/config/functions/bootstrap.js:186:3)
2021-01-11T19:38:00.500466+00:00 app[web.1]: at async Promise.all (index 6)
2021-01-11T19:38:00.500466+00:00 app[web.1]: at async Strapi.runBootstrapFunctions (/app/node_modules/strapi/lib/Strapi.js:405:5)
2021-01-11T19:38:00.500467+00:00 app[web.1]: at async Strapi.load (/app/node_modules/strapi/lib/Strapi.js:337:5)
2021-01-11T19:38:00.500467+00:00 app[web.1]: at async Strapi.start (/app/node_modules/strapi/lib/Strapi.js:191:9)
2021-01-11T19:38:00.567805+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2021-01-11T19:38:00.568469+00:00 app[web.1]: npm ERR! errno 1

@terchris can you provide your package.json?

Hi @DMehaffy
Thanks for the reply - here is my package.json

{
“name”: “urbalurba-strapi”,
“private”: true,
“version”: “0.1.0”,
“description”: “A Strapi application”,
“scripts”: {
“develop”: “strapi develop”,
“start”: “strapi start”,
“build”: “strapi build”,
“strapi”: “strapi”
},
“devDependencies”: {},
“dependencies”: {
“strapi”: “3.4.1”,
“strapi-admin”: “3.4.1”,
“strapi-connector-mongoose”: “3.4.1”,
“strapi-plugin-content-manager”: “3.4.1”,
“strapi-plugin-content-type-builder”: “3.4.1”,
“strapi-plugin-email”: “3.4.1”,
“strapi-plugin-entity-relationship-chart”: “^3.1.0”,
“strapi-plugin-graphql”: “3.4.1”,
“strapi-plugin-upload”: “3.4.1”,
“strapi-plugin-users-permissions”: “3.4.1”,
“strapi-utils”: “3.4.1”
},
“author”: {
“name”: “A Strapi developer”
},
“strapi”: {
“uuid”: “04c65f0e-da4e-414d-a402-af2891a3fc71”
},
“engines”: {
“node”: “>=10.0.0”,
“npm”: “>=6.0.0”
},
“license”: “MIT”
}

Looks good :thinking: did you update progressively from a much older version in one go? If so I think you might be missing a modification.

Specifically this one:

https://strapi.io/documentation/developer-docs/latest/migration-guide/migration-guide-beta.19-to-beta.19.4.html#route-syntax-changes

Usually when I see references on MongoDB projects to that error, it’s old issues from when we implemented this.

Hi @DMehaffy

I have been doing step by step since last spring when I started using strapi.
Today I did 3.2.0 to ver 3.4.0. Then 3.4.0 to ver 3.4.1

I would like to have a “fresh start” on my strapi installation. Is it possible to create a new strapi app and then copy stuff from the previous install ?
I just have tables and relations.

Regards
Terje

It is possible-ish, some of the migration steps might still need to be applied for the data unless you don’t care about the data.

If you are going that route, I would strongly suggest moving off MongoDB while you are at it and move to something like PG or MariaDB instead.

1 Like

Sounds good to me. I import the data from various other systems and I dump the database now and then during development.

Do you know how to move the code ? (what needs to be copied)

So I can switch from mongodb/Atlas to PG or MariaDB. I’m curious to know why these are better than the mongodb ?

You can yes but if you are using relations there will be a bit of manual migration required to remap the relational IDs.

Heroku + Mongo Atlas inherently is insecure as you need to open your atlas security settings to the public web 0.0.0.0/0 as Heroku doesn’t provide a list of possible IP addresses their connections could come from, and that IP changes every time the dyno restarts. They offer an in-house PG add-on that lives inside their network, so less risk of a data leak.

Depends on what you are referring to, if you have a link to your project I could take a look.

Thanks a lot for your advice @DMehaffy
Updating the code and getting rid of whatever old stuff from beta releases was very simple. At the same time I switched from mongodb to postgres.
I created a new strapi project, selecting postgres as the database. Tested it and made sure it worked fine.
Then copied the ./api and the ./components from my previous strapi into the new.

I needed to rebuild strapi using the cli and it worked fine :slight_smile:

I’m using graphql to access strapi data and I found that all my code worked just fine. The only change I have found so far is that in mongodb the date field was named updatedAt and in postgres the same field is named created_at.

Yup back in the day this was “intended” but moving forward we are starting to use snake_case for all the injected fields. Most likely in v4 we will finally do the breaking change for Mongo users and move them from:

  • createdAt => created_at
  • updatedAt => updated_at

@DMehaffy What do you think of Mysql on AWS Aurora? :thinking:

AWS Aurora itself is a proprietary database built and maintained by the AWS team. It’s not a database we directly support thus we can’t promise it will even work there.

If you want to use a supported database on AWS we recommend AWS RDS: Amazon RDS | Cloud Relational Database | Amazon Web Services

We ourselves within Strapi use it and regularly run tests in AWS including with RDS for PostgreSQL, MySQL, and MariaDB.

2 Likes

Thank you!!