next.js
831ca507 - Log content-free diagnostics when a postponed state fails to parse (#95216)

Commit
17 days ago
Log content-free diagnostics when a postponed state fails to parse (#95216) When a `next-resume` request body fails to parse, `parsePostponedState` logged only the bare underlying error (`Failed to parse postponed state Error: unexpected end of file`), which gives an operator no way to tell whether the body was truncated in transit, carried a complete-but-corrupt resume data cache, or simply was not a postponed state at all. The invariant thrown for a body without a length prefix also embedded the entire raw state in its message, which can be large and may contain sensitive serialized data. This change replaces the bare error log with a helper that derives content-free diagnostics from the serialized state: its total length, the declared postponed-string length, whether that postponed string is fully present, the resume-data-cache tail length and whether it is the empty `null` marker, and the underlying error code. Together these distinguish the failure shapes (a truncated postponed string, a truncated `Z_BUF_ERROR` tail, a corrupt `Z_DATA_ERROR` tail, or a missing length prefix), so the otherwise opaque error becomes actionable in production while never logging the state bytes themselves. The invariant message no longer includes the raw state. The behavior is otherwise unchanged: a malformed body still degrades to a dynamic render and the failure is still logged at error level. A new end-to-end test drives the minimal-mode resume path for each failure shape and asserts that a sentinel placed in the request body never appears in the log.
Author
Parents
Loading