Buuntu / fastapi-react

🚀 Cookiecutter Template for FastAPI + React Projects. Using PostgreSQL, SQLAlchemy, and Docker
MIT License
2.22k stars 349 forks source link

Maximum call stack size exceeded #136

Closed robsannaa closed 3 years ago

robsannaa commented 4 years ago

I am trying to execute the command chmod +x scripts/build.sh ./scripts/build.sh, using the default configuration, however, I am always getting this error:

npm notice 
npm notice New patch version of npm available! 7.0.3 -> 7.0.5
npm notice Changelog: <https://github.com/npm/cli/releases/tag/v7.0.5>
npm notice Run `npm install -g npm@7.0.5` to update!
npm notice 
npm ERR! Maximum call stack size exceeded

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2020-10-24T13_56_07_518Z-debug.log
ERROR: Service 'frontend' failed to build : The command '/bin/sh -c npm rebuild' returned a non-zero code: 1
Starting fastapi-react-project_postgres_1 ... 
Starting fastapi-react-project_postgres_1 ... error

ERROR: for fastapi-react-project_postgres_1  Cannot start service postgres: driver failed programming external connectivity on endpoint fastapi-react-project_postgres_1 (64ddcd8b9c18461c2873dfbb73f31a713928de7744232e764ec2fe7ed78b2dd1): Bind for 0.0.0.0:5432 failed: port is already allocated

ERROR: for postgres  Cannot start service postgres: driver failed programming external connectivity on endpoint fastapi-react-project_postgres_1 (64ddcd8b9c18461c2873dfbb73f31a713928de7744232e764ec2fe7ed78b2dd1): Bind for 0.0.0.0:5432 failed: port is already allocated
ERROR: Encountered errors while bringing up the project.
Starting fastapi-react-project_postgres_1 ... 
Starting fastapi-react-project_postgres_1 ... error

ERROR: for fastapi-react-project_postgres_1  Cannot start service postgres: driver failed programming external connectivity on endpoint fastapi-react-project_postgres_1 (31ccd7b0ce884e6658231ae13ef1be29c5c34888676df38322930a3cdbcb67ed): Bind for 0.0.0.0:5432 failed: port is already allocated

ERROR: for postgres  Cannot start service postgres: driver failed programming external connectivity on endpoint fastapi-react-project_postgres_1 (31ccd7b0ce884e6658231ae13ef1be29c5c34888676df38322930a3cdbcb67ed): Bind for 0.0.0.0:5432 failed: port is already allocated
ERROR: Encountered errors while bringing up the project.

Configuration:

I have found this question, however, I have tried every possible solution without success.

What can be the reason I am getting this?

JasonHoku commented 4 years ago

Your error states the reason right here:

ERROR: for fastapi-react-project_postgres_1 Cannot start service postgres: driver failed programming external connectivity on endpoint fastapi-react-project_postgres_1 (31ccd7b0ce884e6658231ae13ef1be29c5c34888676df38322930a3cdbcb67ed): Bind for 0.0.0.0:5432 failed: port is already allocated

port 5432 cannot open, perhaps another service is running on that port or a firewall is blocking its access?

robsannaa commented 4 years ago

Thanks @JasonHoku, however, this error is generated further. I have stopped all containers and tried from scratch. I can actually connect to postgre using a SQL IDE, but the error I get is originated in the frontend, not in the backend services:

❯ chmod +x scripts/build.sh
./scripts/build.sh
Building frontend
Step 1/11 : FROM node:latest
 ---> ca36fba5ad66
Step 2/11 : ADD package.json /package.json
 ---> Using cache
 ---> 0ad31658dcc7
Step 3/11 : ENV NODE_PATH=/node_modules
 ---> Using cache
 ---> 896cfd31e188
Step 4/11 : ENV PATH=$PATH:/node_modules/.bin
 ---> Using cache
 ---> 1550e86f7f79
Step 5/11 : RUN npm install
 ---> Running in 97d46fc9c1d2
npm notice 
npm notice New patch version of npm available! 7.0.3 -> 7.0.5
npm notice Changelog: <https://github.com/npm/cli/releases/tag/v7.0.5>
npm notice Run `npm install -g npm@7.0.5` to update!
npm notice 
npm ERR! Maximum call stack size exceeded

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2020-10-25T08_57_52_370Z-debug.log
ERROR: Service 'frontend' failed to build : The command '/bin/sh -c npm install' returned a non-zero code: 1
Creating dandalo-insta-wordcloud_backend_run ... done
INFO  [alembic.runtime.migration] Context impl PostgresqlImpl.
INFO  [alembic.runtime.migration] Will assume transactional DDL.
Creating dandalo-insta-wordcloud_backend_run ... done
Creating superuser admin@dandalo-insta-wordcloud.com
Superuser created

then:

❯ docker-compose up -d
Building frontend
Step 1/11 : FROM node:latest
 ---> ca36fba5ad66
Step 2/11 : ADD package.json /package.json
 ---> Using cache
 ---> 0ad31658dcc7
Step 3/11 : ENV NODE_PATH=/node_modules
 ---> Using cache
 ---> 896cfd31e188
Step 4/11 : ENV PATH=$PATH:/node_modules/.bin
 ---> Using cache
 ---> 1550e86f7f79
Step 5/11 : RUN npm install
 ---> Running in 70f26ead488d
npm notice 
npm notice New patch version of npm available! 7.0.3 -> 7.0.5
npm notice Changelog: <https://github.com/npm/cli/releases/tag/v7.0.5>
npm notice Run `npm install -g npm@7.0.5` to update!
npm notice 
npm ERR! Maximum call stack size exceeded

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2020-10-25T08_59_13_818Z-debug.log
ERROR: Service 'frontend' failed to build : The command '/bin/sh -c npm install' returned a non-zero code: 1
pigeonflight commented 4 years ago

I can confirm that I'm getting the same issue:

Step 5/12 : RUN npm install -g npm@7.0.5
 ---> Running in 9501a907a35c
npm notice 
npm notice New patch version of npm available! 7.0.3 -> 7.0.5
npm notice Changelog: <https://github.com/npm/cli/releases/tag/v7.0.5>
npm notice Run `npm install -g npm@7.0.5` to update!
npm notice 
npm ERR! code EXDEV
npm ERR! syscall rename
npm ERR! path /usr/local/lib/node_modules/npm
npm ERR! dest /usr/local/lib/node_modules/.npm-i9nnxROI
npm ERR! errno -18
npm ERR! EXDEV: cross-device link not permitted, rename '/usr/local/lib/node_modules/npm' -> '/usr/local/lib/node_modules/.npm-i9nnxROI'

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2020-10-25T17_36_33_620Z-debug.log
robsannaa commented 4 years ago

Hi @pigeonflight, I have also got the same error when trying to update npm with the suggested command npm install -g npm@7.0.5

pigeonflight commented 4 years ago

@robertosannazzaro I found a solution that works for me:

Edit frontend/Dockerfile and change the image from node:latest to node:14. I think the issue is being caused by a newer version of the node image.

pigeonflight commented 4 years ago

@Buuntu I recommend that the node image for frontend/Dockerfile be pinned to node:14 for now. Unless, of course, you have a better solution.

robsannaa commented 4 years ago

@pigeonflight thanks, I have managed to run it! However, maybe something better can be done: using node:14 leads to a lot of warnings:

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.1.2 (node_modules/react-scripts/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.2.7 (node_modules/jest-haste-map/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN notsup Unsupported engine for watchpack-chokidar2@2.0.0: wanted: {"node":"<8.10.0"} (current: {"node":"14.14.0","npm":"6.14.8"})
npm WARN notsup Not compatible with your version of node/npm: watchpack-chokidar2@2.0.0
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.2.7 (node_modules/watchpack-chokidar2/node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.2.7 (node_modules/webpack-dev-server/node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN connected-react-router@6.8.0 requires a peer of immutable@^3.8.1 || ^4.0.0-rc.1 but none is installed. You must install peer dependencies yourself.
npm WARN connected-react-router@6.8.0 requires a peer of seamless-immutable@^7.1.3 but none is installed. You must install peer dependencies yourself.
npm WARN eslint-config-airbnb@18.2.0 requires a peer of eslint-plugin-import@^2.21.2 but none is installed. You must install peer dependencies yourself.
npm WARN eslint-config-airbnb@18.2.0 requires a peer of eslint-plugin-jsx-a11y@^6.3.0 but none is installed. You must install peer dependencies yourself.
npm WARN eslint-config-airbnb@18.2.0 requires a peer of eslint-plugin-react@^7.20.0 but none is installed. You must install peer dependencies yourself.
npm WARN @testing-library/user-event@12.1.10 requires a peer of @testing-library/dom@>=7.21.4 but none is installed. You must install peer dependencies yourself.
npm WARN eslint-config-airbnb-base@14.2.0 requires a peer of eslint-plugin-import@^2.21.2 but none is installed. You must install peer dependencies yourself.

I'm not an expert with npm and node, but I'm trying to give my two cents.

pigeonflight commented 4 years ago

@robertosannazzaro just some "drive-by" debugging. Still on the learning curve myself. My intuition is that this should be pinned as closely as possible to the most recent LTS release which is 12.19.0 at the moment. So maybe node:12 in the Dockerfile.

Buuntu commented 4 years ago

@robertosannazzaro just some "drive-by" debugging. Still on the learning curve myself. My intuition is that this should be pinned as closely as possible to the most recent LTS release which is 12.19.0 at the moment. So maybe node:12 in the Dockerfile.

I would accept a PR for this @pigeonflight

Buuntu commented 3 years ago

Fixed in #149