Skip to content

feat: Allow --error-path fallback when --error-target error fetch fails#646

Closed
kaddynator wants to merge 7 commits into
jupyterhub:mainfrom
kaddynator:feat/error-target-error-path-fallback
Closed

feat: Allow --error-path fallback when --error-target error fetch fails#646
kaddynator wants to merge 7 commits into
jupyterhub:mainfrom
kaddynator:feat/error-target-error-path-fallback

Conversation

@kaddynator
Copy link
Copy Markdown

@kaddynator kaddynator commented May 8, 2026

Problem:

Today you must choose either --error-target or --error-path. If --error-target is set and the request to the custom error server fails (hub down, connection refused, etc.), CHP only returns the generic plain-text response. Static HTML under --error-path is never used in that case.

Change:

  • Permit both --error-target and --error-path. When --error-target is configured, CHP still tries the custom error URL first. On request error, serve HTML from --error-path using the existing rules ({code}.html, then error.html, else default).

  • Fix --error-path CLI help: it is a directory of HTML files, not another proto://host server.

Add a test that uses an unreachable errorTarget and asserts responses come from the error-path fixtures.

Backward compatibility:
Using only --error-target or only --error-path behaves as before. If both are set, behavior is: dynamic page when reachable; otherwise file-based fallback.

kartravi and others added 2 commits May 7, 2026 17:30
Co-authored-by: vishnuvv27 <vishnuvv27@users.noreply.github.com>
Co-authored-by: vishnuvv27 <vishnuvv27@users.noreply.github.com>
@kaddynator kaddynator force-pushed the feat/error-target-error-path-fallback branch 2 times, most recently from f854698 to d6564b1 Compare May 8, 2026 00:51
kartravi and others added 5 commits May 7, 2026 17:58
Co-authored-by: Cursor <cursoragent@cursor.com>
…rorFromPath

In Node 22+, OutgoingMessage.writable delegates to socket.writable which can
return false for an established server-side socket in certain async callback
contexts (e.g. inside the errorRequest 'error' event callback). This caused
_handleProxyErrorFromPath to silently return without sending any response,
leaving fetch() hanging until the jasmine timeout fired.

Use res.writableEnded (consistent with _handleProxyErrorDefault) and add a
!res.headersSent guard before res.writeHead to match the existing pattern.
Co-authored-by: Cursor <cursoragent@cursor.com>
@minrk
Copy link
Copy Markdown
Member

minrk commented May 8, 2026

This seems like a reasonable goal!

Sorry we haven't communicated it widely yet, so it wasn't clear already before the PR was opened, but we have adopted an LLM policy that requires human authorship of all code and documentation and communication. Since this PR has commits attributed to Cursor, it violates that policy and cannot be accepted, so I will close it. If you'd like to contribute to JupyterHub in the future, please feel free to read our contributing documentation.

@minrk minrk closed this May 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants