question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

tinyhttp doesn't work as server for Next.js

See original GitHub issue

Describe the bug

I often use Next.js framework. It commonly used with Express server. I’ve got an idea to try tinyhttp for my projects (and also to add an example to Next.js repo). But I’ve got some errors and maybe you could tell me what is wrong. I’ll also continue investigate this issue as well.

Error log:

➜  next-tinyhttp yarn dev
yarn run v1.22.5
$ node server.js
event - compiled successfully
> Ready on http://localhost:3000
(node:38326) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'name' of undefined
    at /Users/vitalybaev/Documents/OpenSource/next-tinyhttp/node_modules/@tinyhttp/app/dist/index.cjs:34:97
    at Array.find (<anonymous>)
    at getRouteFromApp (/Users/vitalybaev/Documents/OpenSource/next-tinyhttp/node_modules/@tinyhttp/app/dist/index.cjs:34:58)
    at /Users/vitalybaev/Documents/OpenSource/next-tinyhttp/node_modules/@tinyhttp/app/dist/index.cjs:298:39
    at loop (/Users/vitalybaev/Documents/OpenSource/next-tinyhttp/node_modules/@tinyhttp/app/dist/index.cjs:324:34)
    at /Users/vitalybaev/Documents/OpenSource/next-tinyhttp/node_modules/@tinyhttp/app/dist/index.cjs:308:21
    at loop (/Users/vitalybaev/Documents/OpenSource/next-tinyhttp/node_modules/@tinyhttp/app/dist/index.cjs:324:34)
    at /Users/vitalybaev/Documents/OpenSource/next-tinyhttp/node_modules/@tinyhttp/app/dist/index.cjs:308:21
    at loop (/Users/vitalybaev/Documents/OpenSource/next-tinyhttp/node_modules/@tinyhttp/app/dist/index.cjs:324:34)
    at /Users/vitalybaev/Documents/OpenSource/next-tinyhttp/node_modules/@tinyhttp/app/dist/index.cjs:308:21
(Use `node --trace-warnings ...` to show where the warning was created)
(node:38326) 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(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:38326) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

To Reproduce

  1. Clone https://github.com/vitalybaev/next-tinyhttp
  2. yarn
  3. yarn dev, wait for ready message
  4. Open browser and navigate to the root
  5. But routes /a and /b works well

Expected behavior

Server works fine, especially because tinyhttp aims to be a Express-like server. You could see several custom server examples in Next.js repository (https://github.com/vercel/next.js/tree/canary/examples), directory starts with custom-server-*

Versions

  • node: 14.9.0
  • @tinyhttp/app: 0.5.11

Additional context

Add any other context about the problem here.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
talentlessguycommented, Nov 7, 2020

Fixed server.use in 0.5.12

try now with:

pnpm i @tinyhttp/app@0.5.12
0reactions
allcontributors[bot]commented, Nov 7, 2020

@talentlessguy

I’ve put up a pull request to add @vitalybaev! 🎉

Read more comments on GitHub >

github_iconTop Results From Across the Web

Next.js custom server doesn't work if the server imports ...
Next.js custom server doesn't work if the server imports aysnc-listener and uses Webpack 5 #27792. Closed. danoc opened this issue on Aug 5, ......
Read more >
Advanced Features: Custom Server
js doesn't go through babel or webpack. Make sure the syntax and sources this file requires are compatible with the current node version...
Read more >
Setup - Create a Next.js App
If it doesn't work, please take a look at this page. Run the development server. You now have a new directory called nextjs-blog...
Read more >
Advanced Features: Static HTML Export
js application to static HTML, which can be run standalone without the need of a Node.js server. It is recommended to only use...
Read more >
Supported Browsers and Features
In addition, to reduce bundle size, Next.js will only load these polyfills for browsers that require them. The majority of the web traffic...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found