# @solid-primitives/sse
## 1.0.1
### Patch Changes
- 940c9b2: Fix two CodeQL code scanning alerts.
- `@solid-primitives/i18n`: `richText` no longer takes quadratic time on strings with many unclosed tags such as `…` (polynomial ReDoS). It now finds tags linearly with the same output, and a tag named after an inherited `Object` property such as `` is no longer called as a renderer.
- `@solid-primitives/sse`: the worker handler only calls a stored cleanup function when it is one, so a hostile connection id in a `postMessage` can't trigger an unexpected call.
## 1.0.0
### Major Changes
- ce9b27a: Align `createSSE` with Solid 2.0 async reactivity patterns
### Breaking changes
**`pending` removed from `SSEReturn`**
Use `` for initial load UI and `isPending(() => data())` for stale-while-revalidating. Both are re-exported from this package.
```tsx
// Before
const { data, pending } = createSSE(url);
{data()}
// After — declarative initial load
Connecting…
}>
{data()}
// After — stale-while-revalidating (only true once a value exists and new data is pending)
data())}>Refreshing…
```
**`error` removed from `SSEReturn`**
Terminal errors (connection CLOSED with no retries left) now propagate through `data()` to ``. Non-terminal errors (browser reconnecting) are still surfaced via `onError` callback.
```tsx
// Before
const { data, error } = createSSE(url);
Error: {error()?.type}
// After — single error path via Errored boundary
Connection failed
}>
Connecting…}>
{data()}
```
**`data` type narrowed from `Accessor` to `Accessor`**
The `| undefined` loading hole is removed. When `data()` is not ready it throws `NotReadyError` (caught by ``) or the terminal error (caught by ``); it never returns `undefined` due to pending state.
**SSR stub**: `data()` now throws `NotReadyError` on the server when no `initialValue` is provided (consistent with browser behaviour). Provide `initialValue` for a non-throwing SSR default.
### New primitives
**`makeSSEAsyncIterable(url, options?)`**
Wraps an SSE endpoint as a standard `AsyncIterable`. Each message is one yielded value; terminal errors are thrown. Cleanup runs automatically when the iterator is abandoned.
```ts
for await (const msg of makeSSEAsyncIterable(url)) {
console.log(msg);
}
```
**`createSSEStream(url, options?)`**
Minimal reactive alternative to `createSSE` — returns only a `data: Accessor` backed by an async iterable. Same `` / `` integration, no `source` / `readyState` / `close` / `reconnect`.
```ts
const data = createSSEStream<{ msg: string }>(url, { transform: JSON.parse });
```
### Patch Changes
- 50e36c9: Bump the `solid-js`/`@solidjs/web` peer and dev dependency range to `2.0.0-beta.20`. No API or behavior changes; beta.19/beta.20 introduced no breaking changes upstream (internal tree-shaking work, a new `solid-js/refresh` HMR entry point, and SSR/hydration/`lazy()` bug fixes).
- c98cb2d: Bump the `solid-js`/`@solidjs/web`/`@solidjs/signals`/`babel-preset-solid` peer and dev dependency range to `2.0.0-rc.0`. No API or behavior changes on our end — this tracks upstream's move from the beta series into the release candidate.
- 1b703e1: Bump the `solid-js`/`@solidjs/web`/`@solidjs/signals` peer and dev dependency range to `2.0.0-rc.14`.
- 638c530: Bump the `solid-js`/`@solidjs/web`/`@solidjs/signals` peer and dev dependency range to `2.0.0-rc.9`, and `babel-preset-solid` to `2.0.0-rc.2`.
Two behavior fixes were needed to keep up with upstream changes in this range:
- `@solid-primitives/deep`: `captureStoreUpdates` no longer missed property changes. As of `2.0.0-rc.1` a store's `[$TRACK]` only fires for structural changes (key additions/removals), so leaf value changes stopped being reported. Each node's direct property values are now tracked individually. Updates are still reported at the shallowest node that actually changed.
- `@solid-primitives/storage`: `makePersisted` no longer persists stale data. Signal writes stay pending until the next flush in `2.0.0-rc.1`+, so reading the value back inside the setter returned the _previous_ one — persisting stale data, or removing the stored entry entirely when the previous value was nullish. The value returned by the setter is now persisted directly.
- Updated dependencies [89c5324]
- Updated dependencies [5fc4efa]
- Updated dependencies [4a5bf32]
- Updated dependencies [dd165cd]
- Updated dependencies [7ee755d]
- Updated dependencies [50e36c9]
- Updated dependencies [c98cb2d]
- Updated dependencies [1b703e1]
- Updated dependencies [638c530]
- Updated dependencies [04a170e]
- Updated dependencies [b7ef2f3]
- Updated dependencies [5c23fda]
- @solid-primitives/utils@7.0.0
## 1.0.0-next.4
### Patch Changes
- 1b703e1: Bump the `solid-js`/`@solidjs/web`/`@solidjs/signals` peer and dev dependency range to `2.0.0-rc.14`.
- Updated dependencies [1b703e1]
- @solid-primitives/utils@7.0.0-next.6
## 1.0.0-next.3
### Patch Changes
- 638c530: Bump the `solid-js`/`@solidjs/web`/`@solidjs/signals` peer and dev dependency range to `2.0.0-rc.9`, and `babel-preset-solid` to `2.0.0-rc.2`.
Two behavior fixes were needed to keep up with upstream changes in this range:
- `@solid-primitives/deep`: `captureStoreUpdates` no longer missed property changes. As of `2.0.0-rc.1` a store's `[$TRACK]` only fires for structural changes (key additions/removals), so leaf value changes stopped being reported. Each node's direct property values are now tracked individually. Updates are still reported at the shallowest node that actually changed.
- `@solid-primitives/storage`: `makePersisted` no longer persists stale data. Signal writes stay pending until the next flush in `2.0.0-rc.1`+, so reading the value back inside the setter returned the _previous_ one — persisting stale data, or removing the stored entry entirely when the previous value was nullish. The value returned by the setter is now persisted directly.
- Updated dependencies [7ee755d]
- Updated dependencies [638c530]
- @solid-primitives/utils@7.0.0-next.5
## 1.0.0-next.2
### Patch Changes
- Bump the `solid-js`/`@solidjs/web`/`@solidjs/signals`/`babel-preset-solid` peer and dev dependency range to `2.0.0-rc.0`. No API or behavior changes on our end — this tracks upstream's move from the beta series into the release candidate.
- Updated dependencies
- @solid-primitives/utils@7.0.0-next.4
## 1.0.0-next.1
### Patch Changes
- 50e36c9: Bump the `solid-js`/`@solidjs/web` peer and dev dependency range to `2.0.0-beta.20`. No API or behavior changes; beta.19/beta.20 introduced no breaking changes upstream (internal tree-shaking work, a new `solid-js/refresh` HMR entry point, and SSR/hydration/`lazy()` bug fixes).
- Updated dependencies [50e36c9]
- @solid-primitives/utils@7.0.0-next.2
## 1.0.0-next.0
### Major Changes
- ce9b27a: Align `createSSE` with Solid 2.0 async reactivity patterns
### Breaking changes
**`pending` removed from `SSEReturn`**
Use `` for initial load UI and `isPending(() => data())` for stale-while-revalidating. Both are re-exported from this package.
```tsx
// Before
const { data, pending } = createSSE(url);
{data()}
// After — declarative initial load
Connecting…}>
{data()}
// After — stale-while-revalidating (only true once a value exists and new data is pending)
data())}>Refreshing…
```
**`error` removed from `SSEReturn`**
Terminal errors (connection CLOSED with no retries left) now propagate through `data()` to ``. Non-terminal errors (browser reconnecting) are still surfaced via `onError` callback.
```tsx
// Before
const { data, error } = createSSE(url);
Error: {error()?.type}
// After — single error path via Errored boundary
Connection failed
}>
Connecting…}>
{data()}
```
**`data` type narrowed from `Accessor` to `Accessor`**
The `| undefined` loading hole is removed. When `data()` is not ready it throws `NotReadyError` (caught by ``) or the terminal error (caught by ``); it never returns `undefined` due to pending state.
**SSR stub**: `data()` now throws `NotReadyError` on the server when no `initialValue` is provided (consistent with browser behaviour). Provide `initialValue` for a non-throwing SSR default.
### New primitives
**`makeSSEAsyncIterable(url, options?)`**
Wraps an SSE endpoint as a standard `AsyncIterable`. Each message is one yielded value; terminal errors are thrown. Cleanup runs automatically when the iterator is abandoned.
```ts
for await (const msg of makeSSEAsyncIterable(url)) {
console.log(msg);
}
```
**`createSSEStream(url, options?)`**
Minimal reactive alternative to `createSSE` — returns only a `data: Accessor` backed by an async iterable. Same `` / `` integration, no `source` / `readyState` / `close` / `reconnect`.
```ts
const data = createSSEStream<{ msg: string }>(url, { transform: JSON.parse });
```
### Patch Changes
- Updated dependencies [89c5324]
- Updated dependencies [4a5bf32]
- @solid-primitives/utils@7.0.0-next.0
## 0.0.102
### Patch Changes
- 326d05f: Fix memory leak when app-level retries are exhausted in `createSSE`. Previously, when all reconnect attempts were used up and the `EventSource` was permanently closed, `currentCleanup` was never called — leaving the `EventSource` instance and its event listeners alive in memory, and the `source` signal pointing to a stale handle. Now an `else if` branch explicitly calls `currentCleanup()`, clears the reference, and sets the `source` signal to `undefined`.
## 0.0.101
### Patch Changes
- Updated dependencies [6680ab9]
- @solid-primitives/utils@6.4.0
## 0.0.100
### Initial release
- `makeSSE` — base non-reactive primitive wrapping the browser `EventSource` API
- `createSSE` — reactive primitive with signals for `data`, `error`, and `readyState`, reactive URL support, SSR safety, and configurable app-level reconnection