"Maximum update depth exceeded" only on remote server - javascript

When I build and deploy my project on our NGINX server and then call the app I get the following error:
react-dom.production.min.js:198 Error: Minified React error #185; visit https://reactjs.org/docs/error-decoder.html?invariant=185 for the full message or use the non-minified dev environment for full errors and additional helpful warnings.
at react-dom.production.min.js:13
at c (react-dom.production.min.js:14)
at nc (react-dom.production.min.js:243)
at Object.enqueueSetState (react-dom.production.min.js:130)
at e.y.setState (react.production.min.js:13)
at react-router.js:63
at t (history.js:155)
at history.js:173
at Array.forEach (<anonymous>)
at Object.notifyListeners (history.js:172)
The link in the error shows me the following explanation:
We highly recommend using the development build locally when debugging
your app since it tracks additional debug info and provides helpful
warnings about potential problems in your apps, but if you encounter
an exception while using the production build, this page will
reassemble the original text of the error.
And the error...
Maximum update depth exceeded. This can happen when a component
repeatedly calls setState inside componentWillUpdate or
componentDidUpdate. React limits the number of nested updates to
prevent infinite loops.
When I develop locally, I call the npm run-script dev which does the following:
webpack-dev-server --open --mode development
In my Jenkins job, I do this to build and deploy the application:
npm install --verbose
npm run-script build
Build is doing this: webpack --config ./webpack.config.js --mode production
Now to my problem:
The mentioned error leads to a white page and is not repeatable in my local environment. The error just occurs on the deployed app on the NGINX server.
I really don't know how to solve this issue that only occurs on the server and does not show any hints what the cause of this problem might be, but only tells me to fix this issue locally where the problem is not even present.
Does anyone have an idea what I can do to find out the cause of this, or even know the reason for the bug itself?

Related

unable to host slack bot on vercel

I've created a slack bot that I want to deploy with vercel and I keep getting the error:
Error: Command "npm run build" exited with 1
when running vercel deploy.
In my package.json file I have:
"build": "next build"
which is obviously incorrect as it throws this error.
The vercel docs suggest (https://vercel.com/docs/errors#error-list/missing-build-script)
"scripts": {
"build": "[my-framework] build --output public"
so my question is, what is actually expected in here in order to make this work?
I would really appreciate some help getting the project up and running so I can use it on slack. It works locally just fine, but can't get it up and running without me starting it locally.
Here is the repo: https://github.com/Chaffexd/weds-slack-bot
The correct build script for a nextjs app is next build.
Your script currently has npm run-script build.
Which is actually the equivalent of telling it to run itself over and over, it's self referencing.
Also, as an aside, your app is not going to work on Vercel. Vercel is a serverless environment, meaning long running applications like the one you have written that is continually listening on a port (I imagine when you run it locally it hangs for input) are not supported. You should refactor your app to respond to requests, which can trigger your function.
A good way of building this app on Vercel with NextJS might be to use the NextJS API folder for your application code, and then find a free CRON runner to repeatedly hit that function endpoint every day.

How to fix my app after 'npm audit fix --force'

For some context, I am a web developer by day, but in the evenings, I work on a personal project using React Native, and I'm still fairly new to it. The app was working totally fine up until a couple of days ago, and I'm not entirely what caused it. Even if I revert back in GitHub, things still do not work.
Things that I think have caused it are:
Running 'npm audit fix --force'
Or updating node, npm, or expo-cli
What I've tried so far:
I've gone back to a previous commit where the app was definitely working, tried to start the app ('expo start'), but to no avail
I've made sure the package.json, package-lock.json, and yarn.lock were all reverted, and then ran 'npm install', and the yarn equivalent (I'm aware you shouldn't mix package managers but this has been like it even when the app was working, so fairly sure this isn't the issue)
Un-ignored node_modules/ in .gitignore, then deleted them from the project, and ran 'npm install', and yarn equivalent
Tried clearing all caches (npm, metro etc.)
'expo doctor --fix dependencies'
Tried reverting expo-cli to a previous version, same with npm and node
Debugged the app with remote debugger in Chrome which I'll explain below...
Symptoms of the issue:
It seems to be at build time (I think?) because the app never makes it to any kind of components or screens:Error in iOS simulator when I try to serve my app using 'expo start' and 'i'
r/reactnative - how can I fix my app after 'npm audit fix --force'
Error in iOS simulator when I try to serve my app using 'expo start' and 'i'
The message I'm getting is 'no stack', because of a "}" symbol (pics will be included), and when I trace this down to its root using the remote debugging in chrome, the caught exception that it paused on was something like 'can't use import statement outside of a module', and the line seems to be referring to Babel module:Using Expo remote debugger in Chrome
r/reactnative - how can I fix my app after 'npm audit fix --force'
Using Expo remote debugger in Chrome
When I try to serve the app on web, I get a different Webpack related error (please see screenshots)
I won't put my package.json etc. here because it'll be a wall of text, but here's my repo if anyone would like to see the dev dependencies etc.: https://github.com/braingame-com/bg1
This has caused me so much frustration that I considered just rebuilding the app from scratch because it's not very far along anyway, but I'm really wanting to get my debugging skills up and learn what I had done wrong, rather than taking the easy way out.
What can I try next?

Node js server auto restart [duplicate]

I am running a node.js application in Windows and I want to make it automatically restart if there is an unhandled exception in the code which causes the application to stop.
I have done some research and I found that a combination "Forever" and "Nodemon" can achieve this goal.
I installed both packages globally on my Windows 10 Device.
npm install forever -g
npm install -g nodemon
I tried using the following command to launch my app:
forever start nodemon --exitcrash app.js
However, I get the following error: "nodemon does not exist"
If try just running "nodemon" the application starts which indicates the Nodemon package is installed however, this will not allow the app to restart after a crash.
Am I doing something wrong? Most advice I find online is only relevant to Linux systems.
If you are already using forever, then you can get rid of nodemon. Instead you can use a combination of forever and cluster module. Simply fork the worker in case of exceptions, and it makes your app more scalable too!
If still nodemon is preferable, maybe try installing it globally using the -g flag
Forever and nodemon achieve 2 completely different objectives
nodemon is used to run your application in development mode, where you are frequently changing code, and need to restart the server .It will not restart your application in case of a crash. more about that later
Forever, on the other hand, is for making your application run as a daemon in production. And auto restart if you have uncaught exceptions.
Historically people have used Forever stand alone, or with upstart scripts, running as a linux service one of the most famous being upstart
Current norm is to use PM2

Reactnative error, unable to install the application

So I was trying to create a splash screen in react native.
I followed the following article and after completing all the steps, I cleaned my gradle as well.
https://medium.com/handlebar-labs/how-to-add-a-splash-screen-to-a-react-native-app-ios-and-android-30a3cec835ae
But when I was trying to create the app again after doing the relevant changes. This was the error that was being displayed.
error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup. Run CLI with --verbose flag for more details.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
Since I didn't know where I was making the mistake, hence I have linked my Git Repo as well.
https://github.com/SMAmmar14/reactnative

Uncaught Error: #90211 ExtensionName Error - Node.JS, Heroku, JavaScript App using FusionCharts

After updating my NPM packages, this application stopped working and started throwing the following errors:
**Error Message #1**
Uncaught (in promise) TypeError: Cannot read property 'call' of undefined
at o (fusioncharts.js:13)
at o.t (fusioncharts.js:13)
**Error Message #2**
Uncaught Error: #90211 ExtensionName Error >> A FusionCharts extension must have a getName API or a name property.
at o (fusioncharts.js:13)
at Function.i (fusioncharts.js:13)
at Function.e.addDep (fusioncharts.js:13)
at fusioncharts.js:13
The Error #1 appears once, and Error #2 happens about 30x, until it crashes the app.
Things I tried
Lots of googling about these errors, very little information came up; searched SO and found nothing about these specific errors.
I thought the errors might mean the CDN for FusionCharts was corrupted, so I replaced the CDN and refreshed (tried several options); no change.
I also considered that a global variable may be messing something up, but I double-checked and all of my required dependencies are in the package.json.
I thought it might be related to package managers, so I tried running "NPM install" and "Yarn install" to refresh packages. Nothing.
Does anyone have any ideas about these errors? Or other things I can try?
Solved
This was a package management issue. I was using NPM and Yarn together (known to be risky), and I accidentally used "npm install" to refresh the packages instead of "yarn install". This scrambled the yarn tree for my local environment, creating dependency gaps. I tried "yarn install", but by then it was too late (detailed explanation here)
To fix this, you need to reset your local environment.
Steps I took to resolution:
1. Delete node & yarn and local repository
2. Reinstall node & yarn and download repo
3. Run "yarn install" (builds the dependency tree)
4. Run "yarn start" or "yarn dev"
I'm very relieved this worked. I hope this is helpful, please comment for more detail.
For others that run into this issue, it can also be a matter of mismatch fusioncharts versions between what you have installed with node and what is in the index.html of your project.
<script
type="text/javascript"
src="https://cdn.fusioncharts.com/fusioncharts/3.18.0/fusioncharts.js"
></script>
The version defined here (3.18.0) must match what is installed via node (fusioncharts#3.18.0).
This was the case when using both Fusiontime & Fusioncharts Suites in an angular(v12.2) project.

Categories

Resources