본문 바로가기
Q&A해결2026년 7월 19일1분 읽기

"Cannot set headers after they are sent to the client" 에러가 간헐적으로만 떠요

n
node_seunggi
조회 782댓글 2

운영 로그에 하루에 몇 번씩 이 에러가 찍힙니다. 항상 나는 게 아니라 특정 요청에서 가끔만 나서 재현이 정말 안 돼요.

Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client
    at ServerResponse.setHeader (node:_http_outgoing:...)
    at ServerResponse.header (.../express/lib/response.js:...)

핸들러 안에서 조건 분기해서 res.json을 여러 번 부를 일은 없다고 생각했는데, 문제 라우트를 아무리 봐도 res를 두 번 보내는 데를 못 찾겠습니다. 어떤 요청은 되고 어떤 요청은 안 되고... 대체 뭘 봐야 할까요?

댓글 0

아직 댓글이 없습니다.
Ctrl+Enter로 등록