해결된 질문
작성
·
428
0
안녕하세요 이정환 강사님!
강의 너무 잘 듣고 있습니다.
다름이 아니라 section04로 넘어가면서 서버 데이터 패칭 시 하기와 같은 에러가 발생하는데요
hook.js:608 A tree hydrated but some attributes of the server rendered HTML didn't match the client properties. This won't be patched up. This can happen if a SSR-ed Client Component used:
- A server/client branch if (typeof window !== 'undefined')
.
- Variable input such as Date.now()
or Math.random()
which changes each time it's called.
- Date formatting in a user's locale which doesn't match the server.
- External changing data without sending a snapshot of it along with the HTML.
- Invalid HTML tag nesting.
It can also happen if the client has a browser extension installed which messes with the HTML before React loaded.
https://react.dev/link/hydration-mismatch
...
<HotReload assetPrefix="">
<ReactDevOverlay state={{nextId:1, ...}} dispatcher={{...}}>
<DevRootNotFoundBoundary>
<NotFoundBoundary notFound={<NotAllowedRootNotFoundError>}>
<NotFoundErrorBoundary pathname="/" notFound={<NotAllowedRootNotFoundError>} notFoundStyles={undefined} ...>
<RedirectBoundary>
<RedirectErrorBoundary router={{...}}>
<Head>
<link>
<RootLayout>
<html lang="en">
<body
- cz-shortcut-listen="true"
>
...
서버에러인거 같아서 서버 터미널을 보니
[Nest] 89115 - 2024. 12. 01. 오후 10:22:40 ERROR [ExceptionsHandler]
Invalid this.prisma.book.findMany()
invocation in
/Users/jonghyun/Documents/onebite-books-server-main/src/book/book.service.ts:27:35
24 }
25
26 async findAllBooks() {
→ 27 return await this.prisma.book.findMany(
Error querying the database: FATAL: Tenant or user not found
PrismaClientInitializationError:
Invalid this.prisma.book.findMany()
invocation in
/Users/jonghyun/Documents/onebite-books-server-main/src/book/book.service.ts:27:35
24 }
25
26 async findAllBooks() {
→ 27 return await this.prisma.book.findMany(
Error querying the database: FATAL: Tenant or user not found
at In.handleRequestError (/Users/jonghyun/Documents/onebite-books-server-main/node_modules/@prisma/client/runtime/library.js:122:7154)
at In.handleAndLogRequestError (/Users/jonghyun/Documents/onebite-books-server-main/node_modules/@prisma/client/runtime/library.js:122:6188)
at In.request (/Users/jonghyun/Documents/onebite-books-server-main/node_modules/@prisma/client/runtime/library.js:122:5896)
at l (/Users/jonghyun/Documents/onebite-books-server-main/node_modules/@prisma/client/runtime/library.js:127:11167)
at BookService.findAllBooks (/Users/jonghyun/Documents/onebite-books-server-main/src/book/book.service.ts:27:12)
at /Users/jonghyun/Documents/onebite-books-server-main/node_modules/@nestjs/core/router/router-execution-context.js:46:28
at /Users/jonghyun/Documents/onebite-books-server-main/node_modules/@nestjs/core/router/router-proxy.js:9:17
[Nest] 89115 - 2024. 12. 01. 오후 10:22:40 ERROR [ExceptionsHandler]
Invalid prisma.$queryRawUnsafe()
invocation:
Error querying the database: FATAL: Tenant or user not found
PrismaClientInitializationError:
Invalid prisma.$queryRawUnsafe()
invocation:
Error querying the database: FATAL: Tenant or user not found
at In.handleRequestError (/Users/jonghyun/Documents/onebite-books-server-main/node_modules/@prisma/client/runtime/library.js:122:7154)
at In.handleAndLogRequestError (/Users/jonghyun/Documents/onebite-books-server-main/node_modules/@prisma/client/runtime/library.js:122:6188)
at In.request (/Users/jonghyun/Documents/onebite-books-server-main/node_modules/@prisma/client/runtime/library.js:122:5896)
at l (/Users/jonghyun/Documents/onebite-books-server-main/node_modules/@prisma/client/runtime/library.js:127:11167)
at BookService.findRandomBooks (/Users/jonghyun/Documents/onebite-books-server-main/src/book/book.service.ts:51:12)
at /Users/jonghyun/Documents/onebite-books-server-main/node_modules/@nestjs/core/router/router-execution-context.js:46:28
at /Users/jonghyun/Documents/onebite-books-server-main/node_modules/@nestjs/core/router/router-proxy.js:9:17
[Nest] 89115 - 2024. 12. 01. 오후 10:24:17 ERROR [ExceptionsHandler]
Invalid this.prisma.book.findMany()
invocation in
/Users/jonghyun/Documents/onebite-books-server-main/src/book/book.service.ts:27:35
24 }
25
26 async findAllBooks() {
→ 27 return await this.prisma.book.findMany(
Error querying the database: FATAL: Tenant or user not found
PrismaClientInitializationError:
Invalid this.prisma.book.findMany()
invocation in
/Users/jonghyun/Documents/onebite-books-server-main/src/book/book.service.ts:27:35
24 }
25
26 async findAllBooks() {
→ 27 return await this.prisma.book.findMany(
Error querying the database: FATAL: Tenant or user not found
at In.handleRequestError (/Users/jonghyun/Documents/onebite-books-server-main/node_modules/@prisma/client/runtime/library.js:122:7154)
at In.handleAndLogRequestError (/Users/jonghyun/Documents/onebite-books-server-main/node_modules/@prisma/client/runtime/library.js:122:6188)
at In.request (/Users/jonghyun/Documents/onebite-books-server-main/node_modules/@prisma/client/runtime/library.js:122:5896)
at l (/Users/jonghyun/Documents/onebite-books-server-main/node_modules/@prisma/client/runtime/library.js:127:11167)
at BookService.findAllBooks (/Users/jonghyun/Documents/onebite-books-server-main/src/book/book.service.ts:27:12)
at /Users/jonghyun/Documents/onebite-books-server-main/node_modules/@nestjs/core/router/router-execution-context.js:46:28
at /Users/jonghyun/Documents/onebite-books-server-main/node_modules/@nestjs/core/router/router-proxy.js:9:17
[Nest] 89115 - 2024. 12. 01. 오후 10:24:17 ERROR [ExceptionsHandler]
Invalid prisma.$queryRawUnsafe()
invocation:
이와같은 에러가 발생하는데요 supabase에도 문제가 없고 혹시 .env파일에서의 url에 오타가 있는지 봤지만
DATABASE_URL="postgresql://postgres.hnetjcwhrrrlawdduljl:J8duYElvPI3aY69n@aws-0-ap-northeast-2.pooler.supabase.com:5432/postgres"
아레와 같이 문제는 없었는데 어떤 점이 문제인지 4시간째 찾지 못해서 질문드립니다 ㅠ
답변 2
0
안녕하세요 이정환입니다.
혹시 Supabase 프로젝트가 중단된 상태는 아닌가요? 강의 초반부에 안내드렸듯 일주일 이상 접근이 없을 경우 프로젝트가 자동으로 중단되니 확인 부탁드립니다.
0
안녕하세요, 인프런 AI 인턴입니다. never6500님.
서버 데이터 패칭 시 발생하는 하이드레이션 오류와 PrismaConnectorInitializationError는 시스템 구성 및 데이터베이스 설정과 관련된 복합적인 이슈로 보입니다. 설명하신 오류를 해결하기 위해 몇 가지 접근 방법을 추천드리겠습니다.
하이드레이션 문제는 보통 서버와 클라이언트 사이의 랜더링 결과 차이로 인해 발생합니다. 이 문제 해결을 위해 다음 사항들을 점검해보세요:
데이터 일관성 확인: 서버와 클라이언트가 동일한 데이터를 사용할 수 있도록 데이터가 올바르게 전송되는지 확인해야 합니다.
SSR/CSR 분리: 이슈가 발생하는 컴포넌트에서 if (typeof window !== 'undefined')
같은 구문 사용을 점검하여, 서버에만 있는 특정 로직이 클라이언트에서도 실행되지 않도록 분리합니다.
외부 데이터 동기화: 클라이언트와 서버에서 사용하는 외부 API나 데이터가 서로 다르지 않도록 일관성을 유지합니다.
Prisma의 데이터베이스 연결 오류는 .env
파일 설정, 데이터베이스 권한 및 네트워크 환경 등 다양한 요소가 원인이 될 수 있습니다. 다음 사항을 점검하세요:
환경 변수 확인: .env
파일의 DATABASE_URL
을 다시 한 번 확인해주세요. 입력한 URL 중에서 잘못된 부위는 없는지, 추가적인 떨어진 줄바꿈이 발생하는 문자가 있는지도 점검해야 합니다. 특히, 쿼리를 일괄적으로 실행할 때 발생하는 추가적인 문자가 없도록 합니다.
데이터베이스 권한: 데이터베이스 사용자의 권한이 올바르게 설정된 것인지 확인합니다. 예를 들어, postgres
사용자가 원하는 데이터베이스에 접근할 수 있는 권한이 있는지 검사합니다.
네트워크 연결: 데이터베이스 서버로의 네트워크 연결이 SSPL/OpenVPN/DNS 문제 없이 올바르게 동작하고 있는지 확인하세요.
이와 관련된 유사한 사례 및 설명은 아래 링크를 통해 참조하실 수 있습니다:
위 내용이 도움이 되기를 바랍니다. 추가적인 질문이나 문제가 있다면 이어서 질문해 주세요. 보다 구체적인 환경 설정이나 코드에 대한 정보가 있으면 더 정확한 도움을 드릴 수 있습니다.
저는 질문자님의 이해를 돕고자 지식공유자님의 기존 답변을 참고하여 유사한 답변 링크를 추천해드리고 있습니다.
현재 베타 기능으로 답변이 만족스럽지 않을 수 있는 점 양해 부탁드립니다. 🙏
추가적으로 궁금한 점이 있으시면, 이어서 질문해 주세요. 곧 지식공유자께서 답변해 주실 것입니다.