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

UnhandledPromiseRejectionWarning thrown when content-type is not sent #94

Open
v3rse opened this issue Jan 18, 2019 · 1 comment · May be fixed by #95
Open

UnhandledPromiseRejectionWarning thrown when content-type is not sent #94

v3rse opened this issue Jan 18, 2019 · 1 comment · May be fixed by #95

Comments

@v3rse
Copy link

v3rse commented Jan 18, 2019

Issue summary

micro-dev throws the following:

(node:29516) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'indexOf' of undefined
    at logRequest (/home/v3rse/TheFactory/code/learn/javascript/playground/frameworks/micro/hello-micro/node_modules/micro-dev/lib/log.js:38:71)
    at initLog (/home/v3rse/TheFactory/code/learn/javascript/playground/frameworks/micro/hello-micro/node_modules/micro-dev/lib/log.js:97:23)
    at /home/v3rse/TheFactory/code/learn/javascript/playground/frameworks/micro/hello-micro/node_modules/micro-dev/lib/log.js:123:2
    at resolve (/home/v3rse/TheFactory/code/learn/javascript/playground/frameworks/micro/hello-micro/node_modules/micro/lib/index.js:96:33)
    at new Promise (<anonymous>)
    at Function.exports.run (/home/v3rse/TheFactory/code/learn/javascript/playground/frameworks/micro/hello-micro/node_modules/micro/lib/index.js:96:2)
    at Server.server (/home/v3rse/TheFactory/code/learn/javascript/playground/frameworks/micro/hello-micro/node_modules/micro/lib/index.js:13:50)
    at emitTwo (events.js:126:13)
    at Server.emit (events.js:214:7)
    at parserOnIncoming (_http_server.js:656:12)
(node:29516) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 3)
(node:29516) PromiseRejectionHandledWarning: Promise rejection was handled asynchronously (rejection id: 2)

From what I can tell this happens on the following line when a content-type is not sent in the header:
https://github.com/zeit/micro-dev/blob/7ea8ae05a56fa76788bed6fc9ee2d38728e0eac6/lib/log.js#L38

How to reproduced:

  1. Set a simple micro project
module.exports = () => 'Hello'
  1. Run it using micro-dev
  2. Send the following to localhost:3000 without setting a content-type header
POST http://localhost:3000/

{
  "test": "some-data"
}

You should see the above error in your console

@v3rse
Copy link
Author

v3rse commented Jan 18, 2019

Will push a PR for this soon

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

Successfully merging a pull request may close this issue.

1 participant