vercel / next.js

The React Framework
https://nextjs.org
MIT License
125.51k stars 26.81k forks source link

Create "with-mongodb-mongoose" in app router #59819

Open ameetmadan opened 9 months ago

ameetmadan commented 9 months ago

Verify canary release

Provide environment information

Operating System:
  Platform: darwin
  Arch: x64
  Version: Darwin Kernel Version 23.0.0: Fri Sep 15 14:41:43 PDT 2023; root:xnu-10002.1.13~1/RELEASE_ARM64_T6000
Binaries:
  Node: 20.8.0
  npm: 8.15.0
  Yarn: 1.22.19
  pnpm: 8.6.9
Relevant Packages:
  next: 14.0.5-canary.20
  eslint-config-next: 14.0.4
  react: 18.2.0
  react-dom: 18.2.0
  typescript: 5.3.3
Next.js Config:
  output: N/A

Which example does this report relate to?

with-mongodb-mongoose

What browser are you using? (if relevant)

Brave

How are you deploying your application? (if relevant)

Vercel

Describe the Bug

Create a version with app router

Expected Behavior

Working when using dynamic route [id], but always returns undefined even with copied code from docs

To Reproduce

Get example "with-mongodb-mongoose" and run

ameetmadan commented 9 months ago
⨯ TypeError: Cannot read properties of undefined (reading 'id')
    at GET (webpack-internal:///(rsc)/./src/app/api/entities/[id]/route.ts:15:32)
    at /Users/ameetmadan/Documents/Workspace/saas-mvp-template/node_modules/next/dist/compiled/next-server/app-route.runtime.dev.js:6:63192
    at /Users/ameetmadan/Documents/Workspace/saas-mvp-template/node_modules/next/dist/server/lib/trace/tracer.js:133:36
    at NoopContextManager.with (/Users/ameetmadan/Documents/Workspace/saas-mvp-template/node_modules/next/dist/compiled/@opentelemetry/api/index.js:1:7062)
    at ContextAPI.with (/Users/ameetmadan/Documents/Workspace/saas-mvp-template/node_modules/next/dist/compiled/@opentelemetry/api/index.js:1:518)
    at NoopTracer.startActiveSpan (/Users/ameetmadan/Documents/Workspace/saas-mvp-template/node_modules/next/dist/compiled/@opentelemetry/api/index.js:1:18093)
    at ProxyTracer.startActiveSpan (/Users/ameetmadan/Documents/Workspace/saas-mvp-template/node_modules/next/dist/compiled/@opentelemetry/api/index.js:1:18854)
    at /Users/ameetmadan/Documents/Workspace/saas-mvp-template/node_modules/next/dist/server/lib/trace/tracer.js:122:103
    at NoopContextManager.with (/Users/ameetmadan/Documents/Workspace/saas-mvp-template/node_modules/next/dist/compiled/@opentelemetry/api/index.js:1:7062)
    at ContextAPI.with (/Users/ameetmadan/Documents/Workspace/saas-mvp-template/node_modules/next/dist/compiled/@opentelemetry/api/index.js:1:518)
    at NextTracerImpl.trace (/Users/ameetmadan/Documents/Workspace/saas-mvp-template/node_modules/next/dist/server/lib/trace/tracer.js:122:28)
    at /Users/ameetmadan/Documents/Workspace/saas-mvp-template/node_modules/next/dist/compiled/next-server/app-route.runtime.dev.js:6:56649
    at AsyncLocalStorage.run (node:async_hooks:346:14)
    at Object.wrap (/Users/ameetmadan/Documents/Workspace/saas-mvp-template/node_modules/next/dist/compiled/next-server/app-route.runtime.dev.js:6:37037)
    at /Users/ameetmadan/Documents/Workspace/saas-mvp-template/node_modules/next/dist/compiled/next-server/app-route.runtime.dev.js:6:54422
    at AsyncLocalStorage.run (node:async_hooks:346:14)
    at Object.wrap (/Users/ameetmadan/Documents/Workspace/saas-mvp-template/node_modules/next/dist/compiled/next-server/app-route.runtime.dev.js:6:36286)
    at /Users/ameetmadan/Documents/Workspace/saas-mvp-template/node_modules/next/dist/compiled/next-server/app-route.runtime.dev.js:6:54384
    at AsyncLocalStorage.run (node:async_hooks:346:14)
    at eI.execute (/Users/ameetmadan/Documents/Workspace/saas-mvp-template/node_modules/next/dist/compiled/next-server/app-route.runtime.dev.js:6:53777)
    at eI.handle (/Users/ameetmadan/Documents/Workspace/saas-mvp-template/node_modules/next/dist/compiled/next-server/app-route.runtime.dev.js:6:64450)
    at doRender (/Users/ameetmadan/Documents/Workspace/saas-mvp-template/node_modules/next/dist/server/base-server.js:1330:60)
    at cacheEntry.responseCache.get.routeKind (/Users/ameetmadan/Documents/Workspace/saas-mvp-template/node_modules/next/dist/server/base-server.js:1540:46)
    at ResponseCache.get (/Users/ameetmadan/Documents/Workspace/saas-mvp-template/node_modules/next/dist/server/response-cache/index.js:49:26)
    at DevServer.renderToResponseWithComponentsImpl (/Users/ameetmadan/Documents/Workspace/saas-mvp-template/node_modules/next/dist/server/base-server.js:1460:53)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async DevServer.renderPageComponent (/Users/ameetmadan/Documents/Workspace/saas-mvp-template/node_modules/next/dist/server/base-server.js:1853:24)
    at async DevServer.renderToResponseImpl (/Users/ameetmadan/Documents/Workspace/saas-mvp-template/node_modules/next/dist/server/base-server.js:1891:32)
    at async DevServer.pipeImpl (/Users/ameetmadan/Documents/Workspace/saas-mvp-template/node_modules/next/dist/server/base-server.js:909:25)
    at async NextNodeServer.handleCatchallRenderRequest (/Users/ameetmadan/Documents/Workspace/saas-mvp-template/node_modules/next/dist/server/next-server.js:266:17)
    at async DevServer.handleRequestImpl (/Users/ameetmadan/Documents/Workspace/saas-mvp-template/node_modules/next/dist/server/base-server.js:805:17)
<w> [webpack.cache.PackFileCacheStrategy] Caching failed for pack: Error: Unable to snapshot resolve dependencies
CodeTorso commented 7 months ago

Working on this

MehfoozurRehman commented 5 months ago

@CodeTorso I also wanted the Mongoose example with the next 14 and am thinking of doing it myself so please let me know what the status of this issue is and if you need any help with this?