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
691 changes: 691 additions & 0 deletions .github/scripts/setup-vercel-example.sh

Large diffs are not rendered by default.

44 changes: 44 additions & 0 deletions .github/workflows/setup-vercel-example.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Set up Vercel example

on:
workflow_dispatch:
inputs:
example_name:
description:
"Name of the example's folder in the `examples/` directory (e.g.
`nextjs-comments`)"
required: true
type: string
framework:
description: "Framework preset (e.g. `nextjs`)"
required: false
type: choice
# Source: https://vercel.com/docs/rest-api/projects/create-a-new-project#framework
options:
# `choice` inputs can't be optional, so `""` acts as `null`.
- ""
- nextjs
- nuxtjs
- svelte
- sveltekit
- vite
- vue

jobs:
setup-vercel-example:
runs-on: ubuntu-latest

steps:
- name: Check out repository
uses: actions/checkout@v4

- name: Create and configure Vercel project
env:
EXAMPLE_NAME: ${{ inputs.example_name }}
FRAMEWORK: ${{ inputs.framework }}
GITHUB_REPOSITORY: ${{ github.repository }}
LIVEBLOCKS_MANAGEMENT_API_TOKEN:
${{ secrets.LIVEBLOCKS_MANAGEMENT_API_TOKEN }}
VERCEL_TEAM_ID: ${{ secrets.VERCEL_TEAM_ID }}
VERCEL_API_TOKEN: ${{ secrets.VERCEL_API_TOKEN }}
run: bash ./.github/scripts/setup-vercel-example.sh
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
## vNEXT (not yet released)

## v3.19.2

### `@liveblocks/client`

- Fix: clients that have `backgroundKeepAliveTimeout` enabled will no longer
disconnect before any pending Yjs updates have been synced to the server.

## v3.19.1

### `@liveblocks/node` and Python SDK
Expand Down
8 changes: 5 additions & 3 deletions docs/pages/platform/management-api.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ delete projects, webhooks, and more.
The Liveblocks Management API is organized around REST. The API has predictable
resource-oriented URLs, accepts form-encoded request bodies, returns
JSON-encoded responses, and uses standard HTTP response codes, authentication,
and verbs. See the [API reference](api-reference/rest-api-endpoints#Management)
for more information.
and verbs. See the
[API reference](/docs/api-reference/rest-api-endpoints#Management) for more
information.

```
https://api.liveblocks.io/v2/management
Expand Down Expand Up @@ -221,5 +222,6 @@ for your use case, please contact

## API reference

See the [API reference](api-reference/rest-api-endpoints#Management) for more
See the
[API reference](/docs/api-reference/rest-api-endpoints#Management) for more
information.
4 changes: 2 additions & 2 deletions docs/pages/platform/rest-api.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ and more.
The Liveblocks API is organized around REST. The API has predictable
resource-oriented URLs, accepts form-encoded request bodies, returns
JSON-encoded responses, and uses standard HTTP response codes, authentication,
and verbs. See the [API reference](api-reference/rest-api-endpoints) for more
information.
and verbs. See the
[API reference](/docs/api-reference/rest-api-endpoints) for more information.

```
https://api.liveblocks.io/v2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,22 @@ export const THIRD_POSITION = makePosition(SECOND_POSITION);
export const FOURTH_POSITION = makePosition(THIRD_POSITION);
export const FIFTH_POSITION = makePosition(FOURTH_POSITION);

export function makeSyncSource(): SyncSource {
/**
* A `SyncSource` that throws on every accessor. Used as a placeholder in
* test fixtures: if a test ever exercises one of these methods, it fails
* loudly.
*/
export function fakeSyncSource(): SyncSource {
return {
setSyncStatus: () => {},
destroy: () => {},
setSyncStatus: () => {
// no-op
},
getStatus: () => {
throw new Error("fakeSyncSource: not implemented");
},
destroy: () => {
// no-op
},
};
}

Expand All @@ -118,7 +130,7 @@ function makeRoomConfig<TM extends BaseMetadata, CM extends BaseMetadata>(
currentUserId: new Signal<string | undefined>(undefined),
}),
// Not used in unit tests (yet)
createSyncSource: makeSyncSource,
createSyncSource: fakeSyncSource,
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ import {
createSerializedList,
createSerializedRegister,
createSerializedRoot,
fakeSyncSource,
FIRST_POSITION,
makeSyncSource,
prepareIsolatedStorageTest,
prepareRoomWithStorage_loadWithDelay,
prepareStorageTest,
Expand Down Expand Up @@ -101,7 +101,7 @@ function createDefaultRoomConfig<
currentUserId: new Signal<string | undefined>(undefined),
}),
// Not used in unit tests (yet)
createSyncSource: makeSyncSource,
createSyncSource: fakeSyncSource,
};
}

Expand Down
6 changes: 5 additions & 1 deletion packages/liveblocks-core/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -979,6 +979,10 @@ export function createClient<U extends BaseUserMeta = DU>(
source.set(status);
}

function getStatus(): InternalSyncStatus {
return source.get();
}

function destroy() {
unsub();
const index = syncStatusSources.findIndex((item) => item === source);
Expand All @@ -993,7 +997,7 @@ export function createClient<U extends BaseUserMeta = DU>(
}
}

return { setSyncStatus, destroy };
return { setSyncStatus, getStatus, destroy };
}

// ----------------------------------------------------------------
Expand Down
6 changes: 4 additions & 2 deletions packages/liveblocks-core/src/room.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1198,6 +1198,7 @@ export interface IYjsProvider {
*/
export interface SyncSource {
setSyncStatus(status: InternalSyncStatus): void;
getStatus(): InternalSyncStatus;
destroy(): void;
}

Expand Down Expand Up @@ -1543,15 +1544,16 @@ export function createRoom<
// - The `backgroundKeepAliveTimeout` client option is configured
// - The browser window has been in the background for at least
// `backgroundKeepAliveTimeout` milliseconds
// - There are no pending changes
// - There are no pending changes scoped to this room (Storage, Yjs)
//
canZombie() {
return (
config.backgroundKeepAliveTimeout !== undefined &&
inBackgroundSince.current !== null &&
Date.now() >
inBackgroundSince.current + config.backgroundKeepAliveTimeout &&
getStorageStatus() !== "synchronizing"
syncSourceForStorage.getStatus() !== "synchronizing" &&
syncSourceForYjs.getStatus() !== "synchronizing"
);
},
};
Expand Down
4 changes: 4 additions & 0 deletions packages/liveblocks-server/src/Room.ts
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,10 @@ type RoomOptions<SM, CM extends JsonObject, C> = {
* that can guarantee that no Ops from other clients can get interleaved
* between the chunk generation until the last chunk has been sent.
* Defaults to true, but is notably NOT safe to use from DOS-KV backends.
*
* @deprecated Only existed to support the DOS-KV backend, which is gone.
* All remaining drivers are streaming-safe; this flag should be removed
* and the streaming path made unconditional.
*/
allowStreaming?: boolean;

Expand Down
Loading
Loading