Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

backend development errors res.status is not a function #96

Open
nikrb opened this issue Feb 12, 2018 · 8 comments
Open

backend development errors res.status is not a function #96

nikrb opened this issue Feb 12, 2018 · 8 comments

Comments

@nikrb
Copy link
Contributor

nikrb commented Feb 12, 2018

get this type error now and then, not sure what's happening.
The development error handler is invoked but for some reason the response object is invalid - are we not calling it correctly?

[0] GET /favicon.ico 500 2006 - 35.651 ms
[0] TypeError: res.status is not a function
[0]     at developmentErrors (/home/nik/projects/voyage3/bears-21/web/handlers/errorHandlers.js:13:7)
[0]     at Layer.handle [as handle_request] (/home/nik/projects/voyage3/bears-21/node_modules/express/lib/router/layer.js:95:5)
[0]     at trim_prefix (/home/nik/projects/voyage3/bears-21/node_modules/express/lib/router/index.js:317:13)
[0]     at /home/nik/projects/voyage3/bears-21/node_modules/express/lib/router/index.js:284:7
[0]     at Function.process_params (/home/nik/projects/voyage3/bears-21/node_modules/express/lib/router/index.js:335:12)
[0]     at next (/home/nik/projects/voyage3/bears-21/node_modules/express/lib/router/index.js:275:10)
[0]     at /home/nik/projects/voyage3/bears-21/node_modules/express/lib/router/index.js:635:15
[0]     at next (/home/nik/projects/voyage3/bears-21/node_modules/express/lib/router/index.js:260:14)
[0]     at Function.handle (/home/nik/projects/voyage3/bears-21/node_modules/express/lib/router/index.js:174:3)
[0]     at router (/home/nik/projects/voyage3/bears-21/node_modules/express/lib/router/index.js:47:12)
[0]     at Layer.handle [as handle_request] (/home/nik/projects/voyage3/bears-21/node_modules/express/lib/router/layer.js:95:5)
[0]     at trim_prefix (/home/nik/projects/voyage3/bears-21/node_modules/express/lib/router/index.js:317:13)
[0]     at /home/nik/projects/voyage3/bears-21/node_modules/express/lib/router/index.js:284:7
[0]     at Function.process_params (/home/nik/projects/voyage3/bears-21/node_modules/express/lib/router/index.js:335:12)
[0]     at next (/home/nik/projects/voyage3/bears-21/node_modules/express/lib/router/index.js:275:10)
[0]     at app.use (/home/nik/projects/voyage3/bears-21/web/app.js:67:10)

@Mortuie
Copy link
Contributor

Mortuie commented Feb 14, 2018

What is happening here ? How did you get this error, what are you doing when it is called ?

@nikrb
Copy link
Contributor Author

nikrb commented Feb 14, 2018

sorry I should have put reprod in issue description. We get it when requesting a non-existant endpoint. I noticed it when fixing the image bug. I have noticed it from time to time as well, but for a specific example, spark up dev and then nav to: http://localhost:3001/5a830sd9s8eh, and you'll see it in the BE console.

@Mortuie
Copy link
Contributor

Mortuie commented Feb 14, 2018

Ill have a look at it. I would suspect that we don't have a catch to catch all errorneous endpoints like that. We have it covered on the frontend, and I don't think you can reprod on live? I suspect on live react router will catch them all. But you're specifically hitting an api endpoint. Which I assume we need to define and just point to a 404 page...

@nikrb
Copy link
Contributor Author

nikrb commented Feb 14, 2018

I agree we probably need a catch all, you mean like a router.all( '*', notFound) at the bottom of web/routes/index.js?
We don't have the error handler plugged in for production. From browser address bar we get Cannot GET /dkjlweih987 returned as a blank web page, but presumably that wouldn't happen from inside the app, we'd just get a 500 error in dev tools.

@Mortuie
Copy link
Contributor

Mortuie commented Feb 15, 2018

That's weird as we do have a catch all on the React-Router side of things.. I thought that would have caught it...

@Mortuie
Copy link
Contributor

Mortuie commented Feb 15, 2018

It looks like our react-router isn't working properly... Hmmmm that's strange...

@nikrb
Copy link
Contributor Author

nikrb commented Feb 15, 2018

it's an api call, so react-router shouldn't get involved, me thinx.

@Mortuie
Copy link
Contributor

Mortuie commented Mar 25, 2018

@vivekimsit @nikrb I think index.js in routes needs a catch all i.e. router.get('*', someCallback());

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants