Search code examples
typescriptnext.jsaws-amplify

Next.js "run dev" fails with "Error: [object Object]"


New to Next.js and not sure how to start debugging this. Code can be found here:

https://github.com/madeupname/ts-next-amplified/blob/main/README.md

Background: I followed the Amplify Next.js tutorial (although Amplify may have nothing to do with this), but chose TypeScript as the language. I added a blank tsconfig.json, which was detected and filled in. Only .ts files at this point are code generated from Amplify. Running 'next dev' gets me a very opaque error:

Error: [object Object]

Call stack from does not list any project code, so I'm not sure how to debug this:

Call Stack
DevServer.renderToResponse
file:///C:/Java/Source/ts-next-amplified/node_modules/next/dist/server/next-server.js (1631:72)
processTicksAndRejections
internal/process/task_queues.js (93:5)
async DevServer.pipe
file:///C:/Java/Source/ts-next-amplified/node_modules/next/dist/server/next-server.js (1148:25)
async Object.fn
file:///C:/Java/Source/ts-next-amplified/node_modules/next/dist/server/next-server.js (949:21)
async Router.execute
file:///C:/Java/Source/ts-next-amplified/node_modules/next/dist/server/router.js (222:32)
async DevServer.run
file:///C:/Java/Source/ts-next-amplified/node_modules/next/dist/server/next-server.js (1125:29)
async DevServer.run
file:///C:/Java/Source/ts-next-amplified/node_modules/next/dist/server/dev/next-dev-server.js (439:20)
async DevServer.handleRequest
file:///C:/Java/Source/ts-next-amplified/node_modules/next/dist/server/next-server.js (320:20)

Tried debugging in IntelliJ, but "toggle break on exception" doesn't work here.

IntelliJ and "next lint" show no coding warnings or errors.


Solution

  • I had a really similar error.

    Server Error
    Error: [object Object]
    
    This error happened while generating the page. Any console logs will be displayed in the terminal window.
    Call Stack
    DevServer.renderToResponse
    file:///Users/***/***/***/node_modules/next/dist/server/next-server.js (1641:72)
    runMicrotasks
    <anonymous>
    processTicksAndRejections
    node:internal/process/task_queues (96:5)
    async DevServer.pipe
    file:///Users/***/***/***/node_modules/next/dist/server/next-server.js (1158:25)
    async Object.fn
    file:///Users/***/***/***/node_modules/next/dist/server/next-server.js (959:21)
    async Router.execute
    file:///Users/***/***/***/node_modules/next/dist/server/router.js (222:32)
    async DevServer.run
    file:///Users/***/***/***/node_modules/next/dist/server/next-server.js (1135:29)
    async DevServer.run
    file:///Users/***/***/***/node_modules/next/dist/server/dev/next-dev-server.js (445:20)
    async DevServer.handleRequest
    file:///Users/***/***/***/node_modules/next/dist/server/next-server.js (325:20)
    

    It was fixed by downgrading Next.js from 12 to 11. Currently, Next.js v12 is not supported by Amplify.

    https://github.com/aws-amplify/amplify-console/issues/2343