@timber-js/app 0.2.0-alpha.46 → 0.2.0-alpha.48

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"ssr-renderer.d.ts","sourceRoot":"","sources":["../../../src/server/rsc-entry/ssr-renderer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAIxE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEvD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AAC9E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAYrE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAGrD,UAAU,gBAAgB;IACxB,GAAG,EAAE,OAAO,CAAC;IACb,SAAS,EAAE,cAAc,CAAC,UAAU,CAAC,CAAC;IACtC,OAAO,EAAE,aAAa,CAAC;IACvB,QAAQ,EAAE,mBAAmB,EAAE,CAAC;IAChC,gBAAgB,EAAE,oBAAoB,EAAE,CAAC;IACzC,KAAK,EAAE,UAAU,CAAC;IAClB,eAAe,EAAE,OAAO,CAAC;IACzB,eAAe,EAAE,qBAAqB,CAAC;IACvC,gBAAgB,EAAE,OAAO,CAAC;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,iBAAiB,CAAC,IAAI,EAAE,gBAAgB,GAAG,OAAO,CAAC,QAAQ,CAAC,CA4MjF"}
1
+ {"version":3,"file":"ssr-renderer.d.ts","sourceRoot":"","sources":["../../../src/server/rsc-entry/ssr-renderer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,qBAAqB,EAA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AC1C,iCAAiC;IACjC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACrC,qCAAqC;IACrC,UAAU,EAAE,MAAM,CAAC;IACnB,6CAA6C;IAC7C,eAAe,EAAE,OAAO,CAAC;IACzB,0DAA0D;IAC1D,QAAQ,EAAE,MAAM,CAAC;IACjB,8EAA8E;IAC9E,sBAAsB,EAAE,MAAM,CAAC;IAC/B,qEAAqE;IACrE,SAAS,CAAC,EAAE,cAAc,CAAC,UAAU,CAAC,CAAC;IACvC;;;0DAGsD;IACtD,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;iFAE6E;IAC7E,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB;4DACwD;IACxD,OAAO,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9B;;;;;OAKG;IACH,sBAAsB,CAAC,EAAE,OAAO,CAAC;IAEjC;;;;;;;OAOG;IACH,WAAW,CAAC,EAAE;QACZ,gFAAgF;QAChF,QAAQ,EAAE,MAAM,CAAC;QACjB,uDAAuD;QACvD,OAAO,EAAE,MAAM,CAAC;QAChB,gEAAgE;QAChE,MAAM,EAAE,MAAM,CAAC;QACf,wEAAwE;QACxE,UAAU,EAAE,MAAM,CAAC;QACnB,+CAA+C;QAC/C,OAAO,EAAE,MAAM,CAAC;QAChB,sDAAsD;QACtD,WAAW,EAAE,OAAO,CAAC;KACtB,CAAC;CACH;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAsB,SAAS,CAC7B,SAAS,EAAE,cAAc,CAAC,UAAU,CAAC,EACrC,UAAU,EAAE,UAAU,GACrB,OAAO,CAAC,QAAQ,CAAC,CA0JnB;AAED,eAAe,SAAS,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@timber-js/app",
3
- "version": "0.2.0-alpha.46",
3
+ "version": "0.2.0-alpha.48",
4
4
  "description": "Vite-native React framework built for Servers and Serverless Platforms — correct HTTP semantics, real status codes, pages that work without JavaScript",
5
5
  "keywords": [
6
6
  "cloudflare-workers",
@@ -310,6 +310,28 @@ function bootstrap(runtimeConfig: typeof config): void {
310
310
  // Leaving the stream open is harmless: the page is being torn down.
311
311
  function onDOMContentLoaded(): void {
312
312
  if (isPageUnloading()) return;
313
+
314
+ // In dev mode, do NOT close the stream. React's RSC renderer
315
+ // includes debug owner/stack references ($1, $14, etc.) in the
316
+ // Flight payload that point to rows delivered through the debug
317
+ // channel, not the main Flight stream. The browser Flight client
318
+ // tracks these as pending chunks. Closing the stream with
319
+ // unresolved chunks triggers reportGlobalError("Connection closed")
320
+ // which kills the entire React tree.
321
+ //
322
+ // Leaving the stream open is harmless: React has already received
323
+ // all data rows and can hydrate fully. The pending debug chunks
324
+ // just remain unresolved (they're only used for React DevTools
325
+ // component stacks, not rendering).
326
+ //
327
+ // In production, debug rows are not emitted, so closing is safe.
328
+ if (process.env.NODE_ENV === 'development') {
329
+ // Mark as flushed so no more data is buffered, but don't close.
330
+ streamFlushed = true;
331
+ dataBuffer = undefined;
332
+ return;
333
+ }
334
+
313
335
  if (streamWriter && !streamFlushed) {
314
336
  streamWriter.close();
315
337
  streamFlushed = true;
@@ -83,23 +83,7 @@ export async function renderSsrResponse(opts: SsrRenderOptions): Promise<Respons
83
83
 
84
84
  // Tee the RSC stream — one copy goes to SSR for HTML rendering,
85
85
  // the other is inlined in the HTML for client-side hydration.
86
- const [ssrStreamRaw, inlineStream] = rscStream.tee();
87
-
88
- // DEBUG: Log RSC payload as it flows through
89
- const decoder = new TextDecoder();
90
- let rscPayload = '';
91
- const logTransform = new TransformStream<Uint8Array, Uint8Array>({
92
- transform(chunk, controller) {
93
- rscPayload += decoder.decode(chunk, { stream: true });
94
- controller.enqueue(chunk);
95
- },
96
- flush() {
97
- console.error('[timber-debug] RSC payload length:', rscPayload.length);
98
- console.error('[timber-debug] RSC payload (first 2000):\n' + rscPayload.slice(0, 2000));
99
- console.error('[timber-debug] RSC payload (last 500):\n' + rscPayload.slice(-500));
100
- },
101
- });
102
- const ssrStream = ssrStreamRaw.pipeThrough(logTransform);
86
+ const [ssrStream, inlineStream] = rscStream.tee();
103
87
 
104
88
  // Embed segment metadata in HTML for initial hydration.
105
89
  // The client reads this to populate its segment cache before the
@@ -212,8 +212,14 @@ export async function handleSsr(
212
212
  // (eliminates Promise-per-chunk overhead from Web Streams reader)
213
213
  // On Workers: createFromReadableStream (Web Streams are V8-native C++ there)
214
214
  let element: React.ReactNode;
215
- // DEBUG: Force Web Streams path to isolate Node stream conversion issue
216
- element = createFromReadableStream(rscStream) as React.ReactNode;
215
+ if (hasNodeStreamDecode && _nodeStreamImports) {
216
+ const nodeRscStream = _nodeStreamImports.ReadableFromWeb(
217
+ rscStream as import('stream/web').ReadableStream
218
+ );
219
+ element = createFromNodeStream(nodeRscStream) as React.ReactNode;
220
+ } else {
221
+ element = createFromReadableStream(rscStream) as React.ReactNode;
222
+ }
217
223
  const _decodeEnd = performance.now();
218
224
 
219
225
  // Wrap with a server-safe nuqs adapter so that 'use client' components
@@ -248,7 +254,6 @@ export async function handleSsr(
248
254
  renderTimeoutMs,
249
255
  });
250
256
  } catch (renderError) {
251
- console.error('[timber] SSR shell error cause:', renderError);
252
257
  logRenderError({ method: '', path: '', error: renderError });
253
258
  throw new SsrStreamError(
254
259
  'SSR renderToReadableStream failed due to RSC stream error',