piglovesyou / nextjs-passport-oauth-example

5 stars 0 forks source link

TypeError: Converting circular structure to JSON #1

Closed itsdarrylnorris closed 4 years ago

itsdarrylnorris commented 4 years ago

Problem

When I am running this example code I am getting this warning on every page request:

[ warn ]  ./node_modules/express/lib/view.js

Do we have a way to avoid the express warning?

When I am hot reloading, I am getting this error:


Critical dependency: the request of a dependency is an expression
(node:53739) UnhandledPromiseRejectionWarning: TypeError: Converting circular structure to JSON
    --> starting at object with constructor 'NormalModule'
    |     property 'dependencies' -> object with constructor 'Array'
    |     index 0 -> object with constructor 'CommonJsRequireDependency'
    |     ...
    |     index 0 -> object with constructor 'ModuleReason'
    --- property 'module' closes the circle
    at JSON.stringify (<anonymous>)
    at /Users/darrylnorris/Projects/nextjs-passport-oauth-example/node_modules/webpack-hot-middleware/middleware.js:111:38
    at /Users/darrylnorris/Projects/nextjs-passport-oauth-example/node_modules/webpack-hot-middleware/middleware.js:66:7
    at Array.forEach (<anonymous>)
    at everyClient (/Users/darrylnorris/Projects/nextjs-passport-oauth-example/node_modules/webpack-hot-middleware/middleware.js:65:26)
    at Object.publish (/Users/darrylnorris/Projects/nextjs-passport-oauth-example/node_modules/webpack-hot-middleware/middleware.js:110:7)
    at Function.middleware.publish (/Users/darrylnorris/Projects/nextjs-passport-oauth-example/node_modules/webpack-hot-middleware/middleware.js:48:17)
    at HotReloader.send (/Users/darrylnorris/Projects/nextjs-passport-oauth-example/node_modules/next/dist/server/hot-reloader.js:5:678)
    at /Users/darrylnorris/Projects/nextjs-passport-oauth-example/node_modules/next/dist/server/hot-reloader.js:15:508
    at /Users/darrylnorris/Projects/nextjs-passport-oauth-example/node_modules/next/dist/build/output/index.js:5:651
(node:53739) 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: 28)

Have anyone ran into this error before?

piglovesyou commented 4 years ago

@itsdarrylnorris Thanks for trying this. I'm afraid I've seen that too but there's no clue except this open issue.

itsdarrylnorris commented 4 years ago

Hey @piglovesyou ,

What about the express warning? Any thoughts on why this is happening? I tried adding express as dependency and did not fixed.

piglovesyou commented 4 years ago

Ah, I forgot to add express as it's a peerDeps of flow-middleware. Perhaps I need to work on flow-middleware more since it's relatively new. Let me try it in a week.

piglovesyou commented 4 years ago

It seems that I accidentally include express in client-side bundle.

piglovesyou commented 4 years ago

Hmm, from my understanding, calling require('./composePassport') in withIdentity() shouldn't include it in client-side bundle, but it does (running yarn build and then .next/static includes passport code). I need more time to identify the root cause.

piglovesyou commented 4 years ago

@itsdarrylnorris It seems it was just a circular deps just the message describes. I think it was solved.

piglovesyou commented 4 years ago

Wait, it still shows the error

piglovesyou commented 4 years ago

I think 6581a8e5222d311abc6dccc4e7781091aa659da9 is a better solution for exclude server-side module in client bundle.