Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 23 additions & 7 deletions scripts/extract-solid-ref.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,6 @@ const CANONICAL_ROUTES = {
createEffect: ["reactivity/create-effect.mdx", "Reactivity"],
createDeferred: ["reactivity/create-deferred.mdx", "Reactivity"],
createMemo: ["reactivity/create-memo.mdx", "Reactivity"],
createDeferred: [
"`createDeferred` is not `latest` on every consumer. `latest` shows a value now while the update stays held for every other reader; a deferred memo is not part of the update, so nothing waits for it. See [Let a panel lag](/concepts/async-reactivity#let-a-panel-lag-createdeferred).",
"Use it for data that may fall behind the rest of the page without making it wrong, such as an independent widget or a feed. Data that must agree with the rest of the page belongs in `createMemo`.",
"Its first load still suspends to the nearest `Loading` boundary, unless `loadingValue` is set.",
],
createOptimistic: ["reactivity/create-optimistic.mdx", "Reactivity"],
createSignal: ["reactivity/create-signal.mdx", "Reactivity"],
flush: ["reactivity/flush.mdx", "Reactivity"],
Expand Down Expand Up @@ -169,6 +164,10 @@ const CANONICAL_ROUTES = {
render: ["rendering-ssr/render.mdx", "Rendering & SSR"],
renderToStream: ["rendering-ssr/render-to-stream.mdx", "Rendering & SSR"],
renderToString: ["rendering-ssr/render-to-string.mdx", "Rendering & SSR"],
setTrustedTypesPolicy: [
"rendering-ssr/set-trusted-types-policy.mdx",
"Rendering & SSR",
],
takeHydrationValue: [
"rendering-ssr/take-hydration-value.mdx",
"Rendering & SSR",
Expand Down Expand Up @@ -529,6 +528,8 @@ const FOLD_INTO = {
FlightEvent: "attribution",
FlightLink: "attribution",
FlushEvent: "attribution",
FlushChange: "attribution",
FlushLive: "attribution",
GraphEvent: "attribution",
HeldWrite: "attribution",
HoldEvent: "attribution",
Expand Down Expand Up @@ -784,6 +785,16 @@ const HIDDEN_EXPORTS = new Set([
"SOURCE_PROXY",
"SourceKind",
"isStatic",
// @internal re-exports (`export { … } from`) the scan does not see as
// internal: head-registry swap hooks (#4873), the stateful-prop hold read
// (#4872), the verdict window read (#4648), and the dev strict window
// compiled event handler expressions read through (#4838).
"heldRead",
"isHidden",
"setSwapHook",
"verdict",
"strictReadTracked",
"strictHandler",
// The root error hook's storage key; configureClientErrors is the API.
"ROOT_ERROR_HOOK",
// Engine-side owner labelling; records carry the result as `ownerPath`.
Expand Down Expand Up @@ -1778,6 +1789,11 @@ const RETURN_DOCS = {

// Caveats rendered as a bullet list under `## Caveats`.
const ENTRY_CAVEATS = {
createDeferred: [
"`createDeferred` is not `latest` on every consumer. `latest` shows a value now while the update stays held for every other reader; a deferred memo is not part of the update, so nothing waits for it. See [Let a panel lag](/concepts/async-reactivity#let-a-panel-lag-createdeferred).",
"Use it for data that may fall behind the rest of the page without making it wrong, such as an independent widget or a feed. Data that must agree with the rest of the page belongs in `createMemo`.",
"Its first load still suspends to the nearest `Loading` boundary, unless `loadingValue` is set.",
],
createSignal: [
"Passing a function to the setter treats it as an updater. To store a function as the value, wrap it: `setHandler(() => fn)`.",
"A read right after a write returns the old value until the queue flushes. Derive the value you need instead of reading it back, or call `flush()` in tests.",
Expand Down Expand Up @@ -2042,8 +2058,8 @@ const COMPONENT_PROBLEMS = {
"/concepts/components-and-jsx#show-renders-the-fallback-even-though-the-value-is-set",
],
refCallback: [
"An effect or `onCleanup` inside a `ref` callback never runs",
"/concepts/components-and-jsx#an-effect-or-oncleanup-inside-a-ref-callback-never-runs",
"An effect or `onCleanup` inside a `ref` callback throws",
"/concepts/components-and-jsx#an-effect-or-oncleanup-inside-a-ref-callback-throws",
],
};
const LIST_PROBLEMS = {
Expand Down
9 changes: 5 additions & 4 deletions src/routes/(2)concepts/(1)components-and-jsx.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,8 @@ function SearchField() {
A directive is a function you pass to `ref`; there is no separate directive syntax.
A directive factory creates owned reactive primitives during component setup and returns the callback that applies the directive to an element.

Ref callbacks run untracked and without an owner.
Do not create effects or register cleanup inside the returned callback.
A ref callback runs untracked, in the pass that creates the element, and it owns nothing.
Do not create effects or register cleanup inside the returned callback: in development, creating a memo, effect, or root there throws `PRIMITIVE_IN_EFFECT_CALLBACK`, and `onCleanup` throws `CLEANUP_IN_FORBIDDEN_SCOPE`.
Create them in the factory, where they belong to the component owner.

```tsx
Expand Down Expand Up @@ -583,9 +583,10 @@ Keep item identity stable, pass a key function that reads an `id`, or use a [sto
A value of `0` or an empty string is falsy and shows the fallback.
Compare explicitly, for example `when={count() !== undefined}`, or use `Switch` and `Match` when there are several cases.

### An effect or `onCleanup` inside a `ref` callback never runs
### An effect or `onCleanup` inside a `ref` callback throws

Ref callbacks run untracked and without an owner, so primitives created there are never disposed.
A ref callback owns nothing, so nothing could dispose a primitive created there.
In development, a memo, effect, or root created in a ref throws [`PRIMITIVE_IN_EFFECT_CALLBACK`](/reference/solid-js/diagnostics/primitive-in-effect-callback), and `onCleanup` throws [`CLEANUP_IN_FORBIDDEN_SCOPE`](/reference/solid-js/diagnostics/cleanup-in-forbidden-scope).
Create the effect in a directive factory during component setup and return the callback that stores the element.
See [Refs and directives](#refs-and-directives).

Expand Down
17 changes: 17 additions & 0 deletions src/routes/(2)concepts/(6)rendering-and-ssr.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,23 @@ Include it once, before the application markup.
An async read outside any `Loading` boundary blocks the stream's shell.
Put a boundary around the region that depends on the read, so the shell carries a fallback and the content streams later.

### `This document requires 'TrustedHTML' assignment` in the console

The page sends a Content Security Policy with `require-trusted-types-for 'script'`, and the browser rejects the plain string a compiled template assigns to `innerHTML`.
Create a Trusted Types policy in the client entry and pass it to [`setTrustedTypesPolicy`](/reference/solid-web/rendering-ssr/set-trusted-types-policy) before the first `render` or `hydrate`:

```ts
import { setTrustedTypesPolicy } from "@solidjs/web";

setTrustedTypesPolicy(
trustedTypes.createPolicy("my-app", { createHTML: (html) => html })
);
```

Solid then assigns the policy's `TrustedHTML` for template markup, for server component HTML, and for the `html` tagged template.
On the server the call does nothing, so an isomorphic entry can make it.
Name the policy in the page's `trusted-types` directive.

### A promise cached while the page hydrated never resolves

A compute function stored a promise in a cache that outlives it, and the store happened during hydration's tracking run, where promises are stand-ins.
Expand Down
8 changes: 4 additions & 4 deletions src/routes/(5)guides/(13)integrate-non-solid-code.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ The element exists after the JSX has been evaluated; a `ref` callback runs at th

The [`ref` reference](/reference/solid-web/jsx-properties/ref) lists the accepted forms, and [Refs and directives](/concepts/components-and-jsx#refs-and-directives) shows how a directive factory owns setup for an element.
Two things matter for every integration on this page.
A `ref` callback runs untracked and without an owner, so do not create effects or register cleanup in it.
A `ref` callback runs untracked and owns nothing, so do not create effects or register cleanup in it.
And setup that needs the element to be in the document belongs in `onSettled`, which runs after the first render has settled.

## Create the instance once, update it in an effect
Expand Down Expand Up @@ -301,11 +301,11 @@ Use the `prop:` namespace, `prop:disabledDates={holidays()}`, so Solid assigns t
Add the listener from a `ref` directive with the exact name.
If the event uses a delegated name such as `input` and the element dispatches it without `bubbles: true`, the root listener never sees it either.

### An effect or cleanup inside a `ref` callback never runs
### An effect or cleanup inside a `ref` callback throws

Ref callbacks run without an owner.
A ref callback owns nothing, so in development an effect or `onCleanup` created there throws.
Move the setup into `onSettled` in the component body, or into a directive factory that returns the callback.
See [An effect or onCleanup inside a ref callback never runs](/concepts/components-and-jsx#an-effect-or-oncleanup-inside-a-ref-callback-never-runs).
See [An effect or onCleanup inside a ref callback throws](/concepts/components-and-jsx#an-effect-or-oncleanup-inside-a-ref-callback-throws).

## Recap

Expand Down
2 changes: 1 addition & 1 deletion src/routes/(6)migration/(5)from-react.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -1218,7 +1218,7 @@ Development builds report most of them by code; codes marked "attribution" appea
| Reading a signal after `await` in an async memo | The memo does not re-run when it changes | [`UNTRACKED_READ_AFTER_AWAIT`](/reference/solid-js/diagnostics/untracked-read-after-await) (V8 engines) |
| Writing a store outside its setter | The write is ignored | [`STORE_WRITE_OUTSIDE_SETTER`](/reference/solid-js/diagnostics/store-write-outside-setter) |
| `createContext<T \| undefined>(undefined)` for an optional context | `useContext` throws without a provider | `ContextNotFoundError`; use `null` as the default |
| `onClick={ready() ? save : wait}` | The first handler stays bound | Nothing; decide inside one handler |
| `onClick={ready() ? save : wait}` | The first handler stays bound | [`STRICT_READ_UNTRACKED`](/reference/solid-js/diagnostics/strict-read-untracked); decide inside one handler |
| A lowercase `onclick` | The handler is never attached | [`LOWERCASE_EVENT_ATTRIBUTE`](/reference/solid-js/diagnostics/lowercase-event-attribute) |
| A controlled input whose handler rejects a keystroke | The rejected text stays in the field | Nothing; assign `event.currentTarget.value` in the handler |
| `value={props.name} onChange={commit}` with no draft signal | When another attribute in the same template changes, the binding re-runs and erases the typed text | [`UNCOMMITTED_INPUT_OVERWRITTEN`](/reference/solid-js/diagnostics/uncommitted-input-overwritten); write a draft signal from `onInput`, or use `defaultValue` |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ component body or a computation it warns in dev: use `onSettled` there.
- A write in the callback lands after any write made inline in the same
frame. Don't write the same signal both inside and outside it; use a
functional setter if the order matters.
- Several `onFlush` callbacks run in call order and batch into one flush.
- Several `onFlush` callbacks run in call order, each in its own flush:
async work one callback starts does not hold another's writes.
- `queueMicrotask` is not a substitute: called before the frame's first
write, it runs before that flush and its write joins it.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ interface AttributionCostTables {

- **Type:** `ScopeCost[]`

Ranked by self-time.
Ranked by self-time. Collected scopes share one row per name and kind.

#### `writes`

Expand Down Expand Up @@ -1442,6 +1442,43 @@ Summed and worst wall time of landed flights (ms).

- **Type:** `number`

### `FlushChange`

One node whose shown value a drain changed (`FlushEvent.changes`).

```ts
interface FlushChange {
nodeId: number;
nodeName: string;
key?: string;
origin?: ChangeOrigin;
}
```

#### `nodeId`

- **Type:** `number`

The node, in the id space of `RerunEvent.nodeId` and `ChangeRecord.nodeId`.

#### `nodeName`

- **Type:** `string`

#### `key`

- **Type:** `string`

A store property's node: the property, as a string.

#### `origin`

- **Type:** `ChangeOrigin`

Who staged the value that is now shown — the action step, effect,
interaction or navigation — when one was open. A held write keeps the
origin it was staged under, so a landing's changes name their action.

### `FlushEvent`

One `flush()` drain: from the scheduler picking up scheduled work until
Expand All @@ -1459,6 +1496,7 @@ interface FlushEvent {
created: number;
held: boolean;
interaction?: ChangeOrigin;
changes: FlushChange[];
}
```

Expand Down Expand Up @@ -1500,6 +1538,38 @@ The interaction every recorded run of the drain traced to, when there
was exactly one; absent when none did, or when runs for several
interactions shared the drain.

#### `changes`

- **Type:** `FlushChange[]`

What the drain changed on screen: each signal, memo or store property
whose shown value differs from what it showed before the drain — a
commit, a held update's landing, an optimistic value appearing or
lifting. One entry per node, in no promised order. Nodes that got their
first value, and effects, are not listed.

### `FlushLive`

Beside a `flush` record (`OBSERVE.records.subscribe("flush", (event, live) => …)`):
the live side of `event.changes`, index for index — the node, and, for a
listener that subscribed with `{ bodies: true }`, the values before and
after. The values are live, not copies: a store's objects keep changing
after the record, so a listener that keeps them copies them on delivery.

```ts
interface FlushLive {
changes: {
node: Signal<any> | Computed<any>;
prev?: unknown;
value?: unknown;
}[];
}
```

#### `changes`

- **Type:** `{ node: Signal<any> | Computed<any>; prev?: unknown; value?: unknown }[]`

### `GraphEvent`

The live graph's size at a navigation's settle — the moment an app has
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ interface Dev {
getParent: typeof getParent;
getSources: typeof getSources;
getObservers: typeof getObservers;
setSignal: typeof setDevSignal;
report(entry: DiagnosticEvent): void;
guideUrl(code: DiagnosticCode): string;
}
Expand Down Expand Up @@ -81,6 +82,16 @@ interface Dev {

- **Type:** `typeof getObservers`

#### `setSignal`

- **Type:** `typeof setDevSignal`

Write a signal or store-slot node from outside the app's setters —
for example from a devtools state editor that only holds the node from
`getSignals` / `getSources`. Runs as an unowned write (devtools UI
events are not owned scopes). Store property slots go through the
store setter path so `onStoreNodeUpdate` and backing state stay in sync.

#### `report`

- **Type:** `void`
Expand Down Expand Up @@ -169,6 +180,7 @@ type DiagnosticCode =
| "REACTIVE_WRITE_IN_OWNED_SCOPE"
| "ASYNC_STORE_SETTER"
| "STORE_WRITE_OUTSIDE_SETTER"
| "STORE_WRITE_THROUGH_LOADING"
| "ACTION_CALLED_IN_OWNED_SCOPE"
| "RUN_WITH_DISPOSED_OWNER"
| "NO_OWNER_CLEANUP"
Expand All @@ -183,11 +195,13 @@ type DiagnosticCode =
| "NO_OWNER_BOUNDARY"
| "ASYNC_OUTSIDE_LOADING_BOUNDARY"
| "LOADING_ON_OUTSIDE_HOLD"
| "LOADING_ON_ACCESSOR"
| "INVALID_REFRESH_TARGET"
| "INVALID_AFFECTS_TARGET"
| "MISSING_EFFECT_FN"
| "SYNC_NODE_RECEIVED_ASYNC"
| "UNTRACKED_READ_AFTER_AWAIT"
| "CAUGHT_REACTIVE_READ"
| "REACTIVITY_HALTED"
| "INVARIANT_VIOLATION"
| "HUGE_FAN_OUT"
Expand All @@ -207,6 +221,8 @@ type DiagnosticCode =
| "FALLBACK_FLASH"
| "STACKED_HOLDS"
| "OPTIMISTIC_REVERTED"
| "OPTIMISTIC_WRITE_BEFORE_LOAD"
| "OPTIMISTIC_WRITE_WHILE_LOADING"
| "EFFECT_WRITES_OWN_SOURCE"
| "EFFECT_RELAY_TEAR"
| "IMMUTABLE_UPDATE_IN_STORE"
Expand All @@ -231,6 +247,7 @@ type DiagnosticCode =
| "UNSCOPED_HOLE_ALLOCATED_IDS"
| "LOWERCASE_EVENT_ATTRIBUTE"
| "UNCOMMITTED_INPUT_OVERWRITTEN"
| "INVALID_HTML_NESTING"
| "FRAME_MARKER_CORRUPTED"
| "DYNAMIC_ASYNC_COMPONENT"
| "ASYNC_MEMO_ELEMENT";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,7 @@ type DiagnosticCode =
| "REACTIVE_WRITE_IN_OWNED_SCOPE"
| "ASYNC_STORE_SETTER"
| "STORE_WRITE_OUTSIDE_SETTER"
| "STORE_WRITE_THROUGH_LOADING"
| "ACTION_CALLED_IN_OWNED_SCOPE"
| "RUN_WITH_DISPOSED_OWNER"
| "NO_OWNER_CLEANUP"
Expand All @@ -582,11 +583,13 @@ type DiagnosticCode =
| "NO_OWNER_BOUNDARY"
| "ASYNC_OUTSIDE_LOADING_BOUNDARY"
| "LOADING_ON_OUTSIDE_HOLD"
| "LOADING_ON_ACCESSOR"
| "INVALID_REFRESH_TARGET"
| "INVALID_AFFECTS_TARGET"
| "MISSING_EFFECT_FN"
| "SYNC_NODE_RECEIVED_ASYNC"
| "UNTRACKED_READ_AFTER_AWAIT"
| "CAUGHT_REACTIVE_READ"
| "REACTIVITY_HALTED"
| "INVARIANT_VIOLATION"
| "HUGE_FAN_OUT"
Expand All @@ -606,6 +609,8 @@ type DiagnosticCode =
| "FALLBACK_FLASH"
| "STACKED_HOLDS"
| "OPTIMISTIC_REVERTED"
| "OPTIMISTIC_WRITE_BEFORE_LOAD"
| "OPTIMISTIC_WRITE_WHILE_LOADING"
| "EFFECT_WRITES_OWN_SOURCE"
| "EFFECT_RELAY_TEAR"
| "IMMUTABLE_UPDATE_IN_STORE"
Expand All @@ -630,6 +635,7 @@ type DiagnosticCode =
| "UNSCOPED_HOLE_ALLOCATED_IDS"
| "LOWERCASE_EVENT_ATTRIBUTE"
| "UNCOMMITTED_INPUT_OVERWRITTEN"
| "INVALID_HTML_NESTING"
| "FRAME_MARKER_CORRUPTED"
| "DYNAMIC_ASYNC_COMPONENT"
| "ASYNC_MEMO_ELEMENT";
Expand Down Expand Up @@ -1299,8 +1305,9 @@ until `attribution.enable()`): `live` is the computation the record is
about where there is one — the node that ran for `rerun`, `create` and
`effect`, the async node for `flight`, the boundary's subtree for
`fallback` (when the boundary reported one), the first held root signal
for `hold` (the subject the SILENT_HOLD finding names) — and `undefined`
for the records with no single subject (`flush`, `interaction`,
for `hold` (the subject the SILENT_HOLD finding names), the changed
nodes for `flush` (`FlushLive`, with their values under `bodies`) — and
`undefined` for the records with no single subject (`interaction`,
`navigation`, `graph`). The records are the same objects the engine's
ring buffers hold (`attribution.history(type)`), delivered synchronously
the moment each is complete — a re-run at recompute end, a hold, a
Expand All @@ -1317,7 +1324,7 @@ interface RecordTypes extends HostRecordTypes {
rerun: { event: RerunEvent; live: Computed<any> };
create: { event: CreateEvent; live: Computed<any> };
effect: { event: EffectRunEvent; live: Computed<any> };
flush: { event: FlushEvent; live: undefined };
flush: { event: FlushEvent; live: FlushLive };
flight: { event: FlightEvent; live: Computed<any> };
fallback: { event: FallbackEvent; live: Computed<any> | undefined };
interaction: { event: InteractionEvent; live: undefined };
Expand All @@ -1341,7 +1348,7 @@ interface RecordTypes extends HostRecordTypes {

#### `flush`

- **Type:** `{ event: FlushEvent; live: undefined }`
- **Type:** `{ event: FlushEvent; live: FlushLive }`

#### `flight`

Expand Down
Loading
Loading