l3montree-dev / l3montree-dev/devguard
Login redirect crashes with ERR_HTTP_HEADERS_SENT after middleware fetch failure
Open
Nobody has claimed this yet.
bug
component/devguard-web
priority:high
- Dominant language
- Go
- Stars
- 161
- Forks
- 43
- Avg merge
- 1d 8h
- Merged PRs (30d)
- 37
Description
Error
Error: Cannot append headers after they are sent to the client
Stack trace
ServerResponse.appendHeader (node:_http_outgoing:746)
← handleResponse (next/dist/esm/build/templates/app-page.js [_not-found/page]:1119)
← handler (next/dist/esm/build/templates/app-page.js [_not-found/page]:1326)
← NextNodeServer.renderToResponseWithComponentsImpl (next/dist/server/base-server.js:1462)
← NextNodeServer.renderErrorToResponseImpl (next/dist/server/base-server.js:1808)
← pipe.req.req (next/dist/server/base-server.js:1660)
← NextNodeServer.pipeImpl (next/dist/server/base-server.js:1044)
← invokeRender (next/dist/server/lib/router-server.js:266)
← handleRequest (next/dist/server/lib/router-server.js:505)
Source (node_modules/next/dist/esm/build/templates/app-page.js:1114-1124, page=/_not-found/page)
}
} else if (typeof value === 'number') {
value = value.toString();
res.appendHeader(key, value);
} else {
res.appendHeader(key, value);
}
}
}
// Add the cache tags header to the response if it exists and we're in
// minimal mode while rendering a static page.
Request context
- URL:
https://app.devguard.org/self-service/login/browser - Culprit route:
GET /_not-found/page - A middleware
fetch failed(TypeError, viaNextNodeServer.runMiddleware) occurred ~15ms before this error, which appears to have triggered Next's not-found/error rendering path on a response whose headers were already sent, causing theERR_HTTP_HEADERS_SENTcrash.
GlitchTip
- Issue: https://error-tracking.devguard.org/devguard/issues/3418
- Event ID: 019fc7498fa27d4a8ef21afba17ad173
- First seen: 2026-08-03T11:01:54.602Z
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the GET /self-service/login/browser request through NextNodeServer.runMiddleware and the not-found rendering path in next/dist/esm/build/templates/app-page.js:1114-1124. Reproduce the middleware fetch failure and inspect when response headers are sent before handleResponse calls appendHeader. Done means the request no longer crashes with ERR_HTTP_HEADERS_SENT after that failure.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, next.js
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 38/100