Repository navigation
Description
| ID | Issue | Layer | Status |
|---|---|---|---|
| JS-01 | Expressions inside <script> raw-text content are emitted literally |
TSRX compiler | Open; workaround validated |
| JS-02 | Expression-only directive arms can lose render output | TSRX compiler | Locally patched |
| JS-03 | Static-never hydration emits an unnecessary wrapper | SSR runtime | Locally patched |
| JS-04 | Eager entropy initialization is problematic in Workers | Runtime/Cloudflare | Fixed upstream |
| JS-05 | A lazy SSR entry can accidentally retain a large foreign-framework closure | Bundling/SSR | Integration corrected; guard required |
| JS-06 | Deferring static-asset fetch behind a dynamic import creates a cold waterfall | Worker/SSR | Integration corrected |
| JS-07 | Buffered SSR work delays the first response | Streaming/SSR | Improved; general risk remains |
| JS-08 | Released dependency graph could not be reproduced from the configured registry | Toolchain | Open qualification gap |
| JS-09 | Behavior-only entries and externally managed DOM ranges lack first-class lifecycle support | Runtime API | Open design gap |
| JS-10 | Entry, ownership, and deferred-byte information is not sufficiently machine-readable | Compiler/build tooling | Open design gap |
| JS-11 | Cold initialization and warm-stream variance require stronger performance gates | Performance | Improved, still observable |
JS-01 - TSRX expressions inside <script> are emitted as literal source
Status: open compiler behavior. A server-rendering workaround was validated.
The following looks like an ordinary JSX/TSRX expression hole:
<script type="speculationrules">
{JSON.stringify({
prefetch: [
{
eagerness: 'immediate',
where: { selector_matches: '[data-prefetch]' },
},
],
})}
</script>In a production compilation, Octane treated the <script> body as raw text and emitted the expression itself:
<script type="speculationrules">
{JSON.stringify({ prefetch: [...] })}
</script>That is not JSON. Chromium consequently reported syntax errors when parsing the speculation-rules script.
as string does not fix raw-text elements
Octane's normal TSRX convention for a dynamic text hole is:
{expression as string}That convention is appropriate for ordinary element text, but it does not change <script> parsing. This form was production-compiled explicitly:
<script type="speculationrules">
{JSON.stringify(rules) as string}
</script>The compiled server output still contained the complete literal expression, including as string:
"<script type=\"speculationrules\">\n" +
" {JSON.stringify(rules) as string}\n" +
"<\/script>"Valid workaround
Use the explicit raw-script API:
<script
type="speculationrules"
dangerouslySetInnerHTML={{
__html: JSON.stringify({
prefetch: [
{
eagerness: 'immediate',
where: { selector_matches: '[data-prefetch]' },
},
],
}),
}}
/>This compiled through ssrScriptInnerHtml(...), produced valid JSON, and removed all observed browser page errors.
Security consideration: when script data is dynamic, the serializer must prevent </script>, <, and equivalent breakout sequences. dangerouslySetInnerHTML intentionally bypasses normal text escaping.
Recommended compiler behavior: either support expression holes in raw-text/RCDATA elements or produce a compile-time error. Silently preserving valid-looking TSRX source into output is particularly difficult to diagnose.
Suggested regression matrix:
script[type=speculationrules];script[type=application/json];- ordinary executable
<script>; <style>,<textarea>, and other raw-text/RCDATA cases;- SSR and client production compilation;
- dynamic values containing
<,&, quotes, and closing-tag sequences.
JS-02 - expression-only TSRX directive arms can lose render output
Status: locally fixed in c815b057; not present in the evaluated 0.1.12 release head.
A directive arm can be represented in the compiler AST as a block with one expression statement:
BlockStatement
ExpressionStatement
<renderable expression>
The client and SSR compilation passes recognized JSX nodes and returned JSX, but did not consistently promote this expression-only arm into render output. The arm could therefore be handled like an ordinary JavaScript statement instead of being appended to the rendered JSX nodes, resulting in missing or inconsistent output.
The local compatibility patch introduces a narrow normalization:
function promoteDirectiveArmExpression(node) {
if (node?.type !== 'BlockStatement' || node.body?.length !== 1) return node;
const statement = node.body[0];
if (statement?.type !== 'ExpressionStatement' || statement.expression == null) {
return node;
}
return {
type: 'JSXExpressionContainer',
expression: statement.expression,
loc: node.loc || statement.loc,
};
}The normalization is applied in both the SSR-body and client/function-body compilation paths before classifying renderable children.
Why this matters: an SSR/client disagreement at a control-flow boundary can cause missing content, hydration mismatch, or incorrect behavior attachment even if both bundles compile successfully.
Recommended tests: expression-only arms for @if, @for, switch-like and pending/error directives; nested directives; fragments; component and host-element roots; SSR/client byte and DOM-shape parity.
Relevant source:
packages/octane/src/compiler/compile.js
JS-03 - static-never hydration emits an unnecessary wrapper
Status: locally fixed in c815b057; not present in the evaluated 0.1.12 release head.
For an exact, permanently static hydration boundary, conceptually:
<Hydrate split={false} when={never}>
{children}
</Hydrate>the server runtime still created the normal hydration wrapper. That wrapper can:
- expose a hydration marker that will never be consumed;
- change the observable DOM shape and CSS relationships;
- alter namespace or parsing behavior for SVG/foreign content;
- conflict with code that externally owns the rendered range.
The local patch recognizes an exact static-never boundary and renders the children directly while preserving the current namespace:
const directWhen =
typeof props.when !== 'function' && props.when !== null ? props.when : null;
if (props.split === false && directWhen?._t === 'never') {
const childIdStart = ID_COUNTER;
const children = ssrChildrenHtml(props.children, scope);
return MARKERS
? '<!--octane-static-hydrate:' + (ID_COUNTER - childIdStart) + '-->' + children
: children;
}Recommended tests: HTML and SVG children, nested static boundaries, marker-enabled/disabled SSR, empty/multiple children, and DOM-shape parity before and after hydration.
Relevant source:
packages/octane/src/runtime.server.ts
JS-04 - eager entropy initialization is unsafe or unnecessarily expensive in Workers
Status: fixed upstream in the refreshed 0.1.12 release head.
An earlier revision required a Cloudflare lazy-entropy fix. Worker runtimes can restrict, defer, or implement module-level crypto/entropy initialization differently from Node. Eager initialization also adds work to every cold isolate whether or not the feature is used.
The refreshed release already contains the lazy initialization fix, so no local patch was required.
General guidance for runtime libraries:
- avoid environment-dependent crypto/entropy work during module evaluation;
- initialize on first use and cache the result where safe;
- test in actual Worker isolates, not only Node;
- keep the server entry importable without optional platform capabilities.
This issue is distinct from adapter choice: the evaluated host imported octane/server directly into a Worker and did not use an Octane-specific Cloudflare adapter.
JS-05 - a lazy SSR entry can accidentally retain a large foreign-framework closure
Status: corrected in the evaluated integration; should remain a bundle/closure gate.
An Octane server entry imported apparently shared document and rendering helpers. Those helpers, in turn, imported and executed another JSX renderer's SSR implementation. As a result, loading the Octane server path also evaluated a large foreign-framework closure.
The measured lazy import added approximately 1.22 MB raw of SSR modules, including one document/rendering chunk of approximately 866 KB. This cost was paid on first use even though the Octane client entry itself did not contain the other framework.
This is a general ESM/bundling hazard:
small renderer entry
-> shared document helper
-> framework-specific SSR helper
-> JSX/runtime/transcript/component closure
A source-level import that looks harmless can therefore become a substantial cold-start dependency. Type-only intent, asset lookup, HTML-envelope construction, and executed rendering should not share a module boundary when cold startup matters.
General fix pattern
Split framework-neutral utilities from framework-specific rendering:
client-assets.server.ts # manifest/asset lookup only
document-envelope.server.ts # neutral HTML envelope
shell-props.server.ts # serializable shell data
renderer-html.server.ts # renderer-specific HTML
The evaluated build subsequently produced React-free Octane server closures and an import audit found no foreign JSX/SSR imports in the compiled Octane paths.
Recommended guard: follow the emitted SSR manifest/import graph, compute the transitive closure for every lazy server entry, reject disallowed framework imports, and enforce raw/gzip/module-count budgets. Source grep alone is insufficient once bundling and shared chunks are involved.
JS-06 - deferring a static-asset fetch behind a dynamic import creates a cold waterfall
Status: corrected in the evaluated integration.
A prerendered/static shell could be fetched immediately, but its fetch was deferred until after feature selection and a dynamic server-renderer import. The resulting sequence was:
request
-> resolve renderer
-> dynamic import and module evaluation
-> prepare props
-> fetch static shell
-> rewrite/respond
The fetch and module initialization were independent enough to overlap. Starting the asset fetch early changes the sequence to:
request
-> start static-shell fetch -----------------+
-> resolve/import renderer -> prepare props -+-> rewrite/respond
This is particularly important in Workers, where a cold isolate may simultaneously pay module evaluation, manifest lookup, and asset-binding costs.
Recommended guard: add timing markers around static fetch start, dynamic import, prop preparation, and response-prefix emission. Assert that adding a renderer/feature branch does not serialize an otherwise independent asset fetch.
JS-07 - buffered SSR work delays the first response
Status: improved in the evaluated integration; remains a general streaming concern.
The streamed-document path previously rendered several static templates with a separate SSR renderer, buffered them, and then rendered the Octane shell before returning headers. Even when the eventual content was correct, the first byte could not leave until all buffered work completed.
General symptoms include:
- elevated cold TTFB with relatively normal warm completion time;
- first-use
Server-Timingdominated by edge/module work; - an apparently streaming response that does not emit its shell prefix early;
- duplicated template/DOM-shape implementations when replacing a foreign renderer.
Useful mitigation patterns are:
- generate static HTML with a small framework-neutral/native renderer;
- pre-render invariant templates;
- emit the shell prefix before optional/buffered sections;
- keep serialization and escaping shared to prevent renderer drift.
Replacing one renderer with a second handwritten HTML implementation removes the dependency but creates a parity risk. A shared, typed view model plus explicit DOM-shape tests is preferable to duplicating component semantics indefinitely.
JS-08 - the released dependency graph could not be reproduced locally
Status: open qualification gap.
The configured registry rejected the exact released graph involving:
The successful integration build instead used a source-pinned Octane checkout with a cached earlier TSRX dependency (@tsrx/[email protected]). A source build passing does not demonstrate that a clean consumer can install and run the intended published dependency graph.
Recommended qualification:
- install from a clean cache using the exact published lockfile;
- record resolved package versions and integrity values;
- run compiler/runtime tests and a production consumer build;
- test both Node and Worker targets;
- fail release qualification if the source-pinned and published graphs diverge unexpectedly.
This is especially important for a compiler/runtime pair: a small parser or AST-version mismatch can compile successfully while changing production output.
JS-09 - behavior-only entries and externally managed DOM ranges lack a first-class lifecycle
Status: open framework/API design gap.
Some applications do not want an Octane root to create or own the document. They need to attach behavior to server-rendered or externally updated DOM, including ranges that can be replaced after a stream update.
The integration exposed the need for explicit primitives covering:
- behavior-only entries: attach behavior without implying root render/hydration;
- externally owned range lifecycle: adopt, replace, and dispose a DOM range safely;
- post-stream adoption: initialize behavior on content inserted after the initial response;
- streamed-Suspense coordination: coordinate readiness/completion between framework and external stream owners;
- cross-document continuation: transfer the minimal state required across navigation or document replacement;
- dependency/readiness/conflict ordering: define which behaviors initialize first and which cannot coexist.
Without these primitives, consumers tend to build bespoke DOM discovery, mutation observation, state handoff, teardown, and readiness logic. That increases the chance of duplicate listeners, stale closures, orphaned effects, and ownership conflicts.
Suggested API qualities:
type BehaviorEntry = {
id: string;
dependencies?: readonly string[];
conflicts?: readonly string[];
adopt(root: Element | DocumentFragment, context: unknown): void | (() => void);
};The exact API can differ, but adoption and disposal should be explicit, typed, idempotent, and testable. Lifecycle semantics should include replacement during streaming and repeated adoption of the same range.
JS-10 - entry, ownership, and deferred-byte information needs machine-readable tooling
Status: open compiler/build-tooling gap.
The integration required custom analysis to determine what each entry loads, which modules remain eager, which capabilities are deferred, and whether a server closure accidentally contains an unwanted renderer. Existing dead-code and bundle tools need a reliable manifest describing TSRX modules and entries.
Useful machine-readable output would include:
- entry identifiers and transitive module/chunk closure;
- eager versus deferred edges;
- raw, gzip, and Brotli byte counts;
- request/chunk counts;
- client versus server ownership;
- hydration/behavior boundaries;
- optional capability and readiness dependencies;
- source-to-emitted-chunk mapping.
Typed budgets should be enforceable for both initial and lazy capabilities. A capability that is technically deferred but introduces many chunks or unexpectedly large transitive dependencies can still be a performance regression.
The compiler also needs a clear representation for multi-node control-flow bodies. Explicit fragments and a stable entry/module manifest would help AST transforms, dead-code analysis, SSR/client parity checks, and diagnostics.
Recommended guardrails: closure budgets for every public client/server entry, forbidden-import checks, stable manifest snapshots, and a regression test that fails when an eager/deferred edge changes unexpectedly.
JS-11 - cold initialization improved, but residual latency and variance remain
Status: materially improved; additional Worker/deployed qualification recommended.
The initial integration showed a large first-use cost. An order-controlled test alternated renderer order in fresh Workers, then repeated both paths in the same Worker. That distinguished generic Worker startup from lazy-module initialization.
Earlier first-use results were approximately:
| Scenario | TTFB | Edge work |
|---|---|---|
| Static document, Octane first use after another renderer | 17.8 ms | 16 ms |
| Static document, fully cold Octane | 27.9 ms | 20 ms |
| Streamed document, Octane first use after another renderer | 18.4 ms | 16 ms |
| Streamed document, fully cold Octane | 51.1 ms | 42 ms |
After separating the SSR closure and prestarting the static fetch, the comparable medians were:
| Scenario | TTFB | Edge work |
|---|---|---|
| Static document, Octane first use after another renderer | 9.5 ms | 8 ms |
| Static document, fully cold Octane | 17.3 ms | 12 ms |
| Streamed document, Octane first use after another renderer | 18.0 ms | 15 ms |
| Streamed document, fully cold Octane | 43.1 ms | 37 ms |
The static-document improvement closely tracks reduced module/edge work. It is evidence that lazy closure size and request waterfalls, not the basic renderer alone, dominated the original regression.
Final local Worker comparison
Five cold and five warm samples per renderer/route were collected with a deterministic 750 ms stream delay. Medians and ranges:
| Document | Baseline renderer cold | Octane cold | Baseline renderer warm | Octane warm |
|---|---|---|---|---|
| Static | 11.3 [10.0-13.5] ms |
17.8 [17.1-19.7] ms |
1.7 [1.5-2.1] ms |
2.5 [2.2-3.2] ms |
| Streamed | 36.3 [34.3-39.0] ms |
41.5 [40.6-42.0] ms |
7.4 [5.0-9.1] ms |
9.1 [6.1-10.2] ms |
Octane cold medians improved approximately 36% for the static document and 19% for the streamed document relative to the preceding matched snapshot, but still trailed the baseline renderer by roughly 5-7 ms in this local pass.
Warm streamed requests and occasional cold isolates showed wider variance. One cold streamed sample reached roughly 67 ms TTFB/55 ms edge against an otherwise lower family. This should be treated as a profiling target, not evidence of a deterministic regression.
Recommended performance gate: test fresh isolates and both renderer orders, retain Server-Timing/trace markers, and report p50/p95 plus ranges. Correlate outliers with dynamic imports, manifest/asset reads, module evaluation, serialization, and GC.
Browser-side performance context
The JavaScript payload reduction was consistent even where server startup was slower. With Chromium at 4x CPU slowdown, five isolated runs per document/renderer produced:
| Document | Renderer | TTFB | FCP | LCP | Load | CLS | INP |
|---|---|---|---|---|---|---|---|
| Static | Baseline | 3.9 ms | 148 ms | 148 ms | 168 ms | 0 | 48 ms |
| Static | Octane | 4.1 ms | 152 ms | 152 ms | 163 ms | 0 | 40 ms |
| Streamed | Baseline | 7.6 ms | 76 ms | 804 ms | 811 ms | .011 | 16 ms |
| Streamed | Octane | 6.8 ms | 40 ms | 792 ms | 813 ms | .008 | - |
Lighthouse with real devtools 4x CPU throttling produced:
| Document | Renderer | TTFB | FCP | Speed Index | LCP | TTI | TBT | CLS |
|---|---|---|---|---|---|---|---|---|
| Static | Baseline | 3 ms | 129 ms | 129 ms | 129 ms | 137 ms | 0 | 0 |
| Static | Octane | 3 ms | 42 ms | 76 ms | 85 ms | 98 ms | 0 | 0 |
| Streamed | Baseline | 7 ms | 108 ms | 308 ms | 108 ms | 818 ms | 0 | .002 |
| Streamed | Octane | 5 ms | 75 ms | 251 ms | 75 ms | 817 ms | 0 | 0 |
Across the two-document journey, Octane reduced resource transfer from approximately 354 KB to 97 KB (about 73%), encoded resource data by about 75%, and decoded resource data by about 69%. The measured Octane client bundles were approximately:
static-page entry: 11,784 raw / 3,841 gzip bytes
streamed-page entry: 28,418 raw / 8,976 gzip bytes
shared Worker client:126,450 raw / 39,979 gzip bytes
These results demonstrate why isolating server initialization matters: the client-side JavaScript savings are substantial, but an unnecessarily large or serialized SSR closure can hide those benefits in cold TTFB.
Measurement caveats
- A missing INP value means no qualifying Event Timing observation, not zero interaction latency. Short runs did not emit comparable streamed-document INP samples for both renderers.
- Navigation-mode Lighthouse mainly measures the initial shell, while browser LCP can include delayed streamed content.
- Fifteen of twenty Lighthouse traces emitted a load-time-limit warning, although all audits returned values and no trace had a runtime error.
- Static-document paint was occasionally bimodal under Lighthouse, with roughly 37-85 ms FCP and 41-87 ms LCP ranges.
- Local Worker results are useful for controlled diagnosis, but deployed isolate distributions are required before defining a production budget.
Recommended follow-up
- Fix or diagnose raw-text expression handling. Add production-compile fixtures and reject literal TSRX expressions in script/style output.
- Upstream the directive-arm and static-hydration fixes. Include SSR/client and HTML/SVG parity tests.
- Qualify the exact published dependency graph. Test from a clean cache across Node and Worker targets.
- Make server-entry closures observable and enforceable. Add emitted-manifest traversal, forbidden-import checks, and per-entry size/module/request budgets.
- Overlap independent cold-path work. Start asset reads before dynamic imports where possible and emit response prefixes early.
- Define behavior-only/range lifecycle APIs. Make adoption, replacement, disposal, readiness, and conflicts explicit and typed.
- Add deployed cold-isolate profiling. Alternate entry order, record p50/p95 and edge timings, and investigate warm/outlier variance.
Activity
trueadm commentedon Jul 21, 2026
This is not a bug and we shouldn't be fixing it. The correct way to handle this is to wrap it in a fragment. The reason for this is clear, it's confusing. Especially if someone did this:
@if (x) { console.log(value); })We should make this clear somewhere in our docs so people keep getting confused. This is a clear TSRX design choice.