It's happening this: sometimes, when I try to insert a new document (such as a new user,product or sale register) in my MERN app, it works fine, but some other times I'm getting the following in my console:
"Failed to load resource: the server responded with a status of 400 (Bad Request)"
"Uncaught (in promise) Error: Request failed with status code 400"
Also, in previous versions of this app, those things which worked fine previously doesn't work now.
When I restart my computer, sometimes I'm abled to add, for example, a new user, but after that, I'm not. That is, sometimes works and sometimes doesn't.
I think it must be a problem with MongoDB, maybe my computer is out of resources.
I'm using mongoose and axios.
Here's my project in gitLab:
https://gitlab.com/leandrocaplan/final-programacion-iii
A little bit of spanish lesson to understand a little better:
"Usuario" means user, so on, at the section "Alta de empleado (Employee create)", we must create a new user. "Venta" means sale, "Compra" means puchrase, and "Producto" means product.
Does anyone have an idea of what can be happening?
Thank you very much
Leandro
Related
I am following Bezkoder tutorial in the link to create a simple CRUD database using React, NodeJS, Express and MySQL: [https://www.bezkoder.com/react-node-express-mysql/#React_Nodejs_Express_MySQL_Architecture
I've successfully created the backend and tested read, write and delete of records using POSTMAN. I've then created the React frontend, which uses Axios - it compiles OK, and displays a web page in my browser. This page will read records from the database OK, but when I try to add new or amend existing records, it doesn't work, and in console it displays "Request Failed with status code 400" error. The full error message in console is as follows:
Console error
I'm not sure what the error means or how I might go about troubleshooting further. Could anyone point out to me how I can troubleshoot this further or what other info you'd need to help me?
I was expecting the React frontend to be able to add new records and amend existing records.
I work on a full stack application that is composed of:
Django (Django Rest Framework)
React
PostgreSQL database
Redis
Celery
It is deployed through docker. Whole application works well and has no bugs that cannot be traced.
However, when I try to delete Project item from database (this is domain specific), I get error 500 and no specific trace.
I figured this bug out on deployed application. While inspecting Networking tab in Developer Tools I found the request and saw 500 return code. However, nothing was returned in returned in Response.
However, I think something should have been returned. Code is as such:
class ProjectCRUD(GenericAPIView):
# [...]
def delete(self, request, pk):
try:
# [...] code that deletes all referenced values and current project
except ProtectedError as e:
return JsonResponse({
"error": "Project still referenced",
"details": str(e)
}, status=400)
except Exception as e:
return JsonResponse({"error": "Wrong project id"}, status=status.HTTP_400_BAD_REQUEST)
return JsonResponse({
'message': f'Project with id {project_id} was deleted successfully!'
}, status=status.HTTP_204_NO_CONTENT)
# [...]
This "Wrong project id" assumption is by all means bad and this will be refactored as soon as this bug is also found. This code makes sure that if exception is raised, it is caught, something is returned with at least some amount of information given. If exception is not caught, return 204.
So I go to the application, I create a new project, try to delete it and error 500 with nothing in Networking appears.
Next step is trying things locally. I start local server using python manage.py runserver. This doesn't go through docker because redis and celery are not used for this feature. I create a new project, try to delete it and console logs writes 204, which means it passed.
I start docker. Repeat process. Everything works, 204 is returned.
Next I check docker logs of deployed application. This is where it starts to be really weird. Backend logs show 204 as it did locally. Frontend logs show 204 as well. However, client (ie browser) in networking displays error 500.
From searching I concluded that the bug happens somewhere between Frontend and client.
My questions are:
any idea why is this happening
where should I look next in order to catch a bug
So the whole application works as expected except for this feature.
Thanks.
I have a free heroku plan and a nodejs app on the heroku server. The nodejs app is built with meanjs, so the code for mongodb connections is exactly what you would find in the configuration files. I use a mongolab free mongo database to store the data. Occasionally (depending on how much I interact/change code I believe), the mongodb data is corrupted. I believe this to be true because I use a script to register names, and I can always log into them for awhile until I receive a no user/pass error. If I get this error and immediately create a new user, the user can successfully be logged in and out. All of the user data is still in the database. I also have a few other crud modules that use different collections in the same database, and I (so far) have not seen anything happen to that data, or anything to any of the data besides the password. I don't know where my error is possibly coming from, or what code is relevant, as I haven't touched the config files at all and to my knowledge haven't written any code that looks at user passwords at all. Also, my user object is occasionally empty (user = "") in the markup, but that bug was introduced after the original, I believe while I was trying to find out what was going on. Again, I don't have any clue though, so I included it just in case. Thanks!
After a lot of trial and error, I found the cause to my problem.
After I created these users, I go into my Mongolab account and manually edit the roles based on what module I'm working on (doing role based authentication). It is when editing the data that my passwords become corrupted. I don't know why, but I've pinpointed the problem to there. I've messed with some other data, with similar results.
I have this site, a random little one i just play around on with jsf and primefaces.
I have my own domain connected to it, and hosted it on google-app-engine...
It's been working as a charm right up until now. I have not done anything on the site due to vacation time, and suddenly the site is down? It was working when i deployed the last time, now when i go to my site i get this:
Error: Server Error
The server encountered an error and could not complete your request.
If the problem persists, please report your problem and mention this error message and the query that caused it.
It tells me absolutely nothing, i've tried to re deploy my app, after checking that it worked fine running locally. The first couple of time it just kept on waiting for a verify.. So i stopped it, which led me to learn how to do a rollback as i could not redeploy with the same version number after i stopped it the first time.
I got the rollback fixed, and i now deployed what i know i working code to the app-engine, and still when navigating to my site i get the above error? :S
I'm totally clueless here as the error doesn't really give me anything :S
Anyone have any ideas, i can post code etc. if necessary but something tells me that it is something else seeing that my code runs locally, and ran fine deployed too :S
You can find the log file for your web application at
https://appengine.google.com/logs?&app_id=yourappname
or on the Dashboard page in the list on the left side.
If you deploy a new version, also re-start the browser to clear old session data.
(Maybe you still get the 500 error still because of old session data).
I'm getting a strange error in my newly deployed application in appengine. In the error log it tells me that PageRank, TwitterBot and a couple of others. I would guess this is due to these try to get data using ajax or another async service resulting in "same origin policy"-problem.
My question is does anyone know what these bots are trying to get? For example if pagerank (google page rank I would guess) can't get any info about my application would this effect my page rank. And anyone know what the twitterbot does? And if there is away to handle to provide a proper response?
Most likely, your RequestHandlers (I'm assuming you're using python with webapp from the tags on your earlier questions) aren't implementing a method for whichever request method the bots are using. I'd guess they're HEAD requests, and you have no head() methods defined.