Skip to content

Fix CSR fallback crash when SSR returns non-string error#73

Open
m5r wants to merge 1 commit intoinertiajs:mainfrom
m5r:fix/ssr-non-string-error-fallback
Open

Fix CSR fallback crash when SSR returns non-string error#73
m5r wants to merge 1 commit intoinertiajs:mainfrom
m5r:fix/ssr-non-string-error-fallback

Conversation

@m5r
Copy link
Copy Markdown

@m5r m5r commented Apr 1, 2026

Problem

When a Node.js SSR worker crashes (e.g. V8 OOM with exit code 134), the nodejs library returns {:error, {:node_js_worker_exit, <tuple>}} instead of {:error, "string message"}.

In send_response/1, this matches {:error, message} where message is a tuple. The Logger call on line 845 does "...\n\n#{message}", which calls String.Chars.to_string/1 on the tuple and raises Protocol.UndefinedError. The CSR fallback on the next line never executes, and the user gets a 500.

The raise_on_ssr_failure path has the same issue: RenderError expects message to be a string.

Fix

Coerce message with inspect/1 when it's not a binary, before logging or raising:

{:error, message} ->
  message = if is_binary(message), do: message, else: inspect(message)

Test

Added test/js/ssr-crash.js that calls process.exit(134) to simulate a worker crash. The test asserts the request still returns 200 (CSR fallback) instead of crashing.

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.

1 participant