feat(node-streams): add conditional Node stream support to instant-validation
Makes instant-validation.tsx conditionally use Node.js native streams
(renderToPipeableStream) instead of web streams (renderToReadableStream)
when __NEXT_USE_NODE_STREAMS is enabled. This prevents hangs that occurred
when instant-validation bypassed the stream API wrappers.
Changes:
- Remove static import of renderToReadableStream
- Add conditional lazy requires for both web and Node Flight APIs
- Use renderToFlightPipeableStream wrapper for Node path (handles debug channel conversion)
- Handle stream iteration differences (Node Readable vs web ReadableStream.values())
- Apply pattern at both rendering call sites: collectStagedSegmentData and createCombinedPayloadStream
Known limitation:
- Debug channel at segment level disabled with Node streams to avoid parallel bridge issues
- Combined payload level debug channel still enabled
- 4/5 instant-validation tests pass; debug channel interaction needs further investigation
Test results with __NEXT_USE_NODE_STREAMS + __NEXT_CACHE_COMPONENTS + __NEXT_EXPERIMENTAL_DEBUG_CHANNEL:
- instant-validation-static-shells: 4 passed, 1 failing (debug channel interaction)
- Without debug channel: all tests pass
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>