Skip to content

Commit 99793a2

Browse files
Merge remote-tracking branch 'upstream/main' into state-compression
2 parents e9c322f + a2f14e7 commit 99793a2

File tree

108 files changed

+568
-472
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

108 files changed

+568
-472
lines changed

.github/workflows/benchmarks.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ jobs:
8080
fail-fast: false
8181
matrix:
8282
# Show OS combos first in GUI
83-
os: [ubuntu-latest, windows-latest, macos-12]
83+
os: [ubuntu-latest, windows-latest, macos-latest]
8484
python-version: ['3.9.18', '3.10.13', '3.11.5', '3.12.0']
8585
exclude:
8686
- os: windows-latest
@@ -92,7 +92,7 @@ jobs:
9292
python-version: '3.9.18'
9393
- os: macos-latest
9494
python-version: '3.10.13'
95-
- os: macos-12
95+
- os: macos-latest
9696
python-version: '3.12.0'
9797
include:
9898
- os: windows-latest
@@ -155,7 +155,7 @@ jobs:
155155
fail-fast: false
156156
matrix:
157157
# Show OS combos first in GUI
158-
os: [ubuntu-latest, windows-latest, macos-12]
158+
os: [ubuntu-latest, windows-latest, macos-latest]
159159
python-version: ['3.11.5']
160160

161161
runs-on: ${{ matrix.os }}

.github/workflows/check_outdated_dependencies.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ jobs:
5858
working-directory: ./reflex-web
5959
run: poetry run uv pip install -r requirements.txt
6060
- name: Install additional dependencies for DB access
61-
run: poetry run uv pip install psycopg2-binary
61+
run: poetry run uv pip install psycopg
6262
- name: Init Website for reflex-web
6363
working-directory: ./reflex-web
6464
run: poetry run reflex init

.github/workflows/integration_app_harness.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ jobs:
2222
timeout-minutes: 30
2323
strategy:
2424
matrix:
25-
state_manager: ["redis", "memory"]
25+
state_manager: ['redis', 'memory']
26+
python-version: ['3.11.5', '3.12.0', '3.13.0']
2627
split_index: [1, 2]
27-
python-version: ["3.11.5", "3.12.0"]
2828
fail-fast: false
2929
runs-on: ubuntu-22.04
3030
services:

.github/workflows/integration_tests.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
matrix:
4444
# Show OS combos first in GUI
4545
os: [ubuntu-latest, windows-latest]
46-
python-version: ['3.9.18', '3.10.13', '3.11.5', '3.12.0']
46+
python-version: ['3.9.18', '3.10.13', '3.11.5', '3.12.0', '3.13.0']
4747
exclude:
4848
- os: windows-latest
4949
python-version: '3.10.13'
@@ -73,7 +73,7 @@ jobs:
7373
run: |
7474
poetry run uv pip install -r requirements.txt
7575
- name: Install additional dependencies for DB access
76-
run: poetry run uv pip install psycopg2-binary
76+
run: poetry run uv pip install psycopg
7777
- name: Check export --backend-only before init for counter example
7878
working-directory: ./reflex-examples/counter
7979
run: |
@@ -147,7 +147,7 @@ jobs:
147147
working-directory: ./reflex-web
148148
run: poetry run uv pip install $(grep -ivE "reflex " requirements.txt)
149149
- name: Install additional dependencies for DB access
150-
run: poetry run uv pip install psycopg2-binary
150+
run: poetry run uv pip install psycopg
151151
- name: Init Website for reflex-web
152152
working-directory: ./reflex-web
153153
run: poetry run reflex init
@@ -198,7 +198,7 @@ jobs:
198198
fail-fast: false
199199
matrix:
200200
python-version: ['3.11.5', '3.12.0']
201-
runs-on: macos-12
201+
runs-on: macos-latest
202202
steps:
203203
- uses: actions/checkout@v4
204204
- uses: ./.github/actions/setup_build_env
@@ -216,7 +216,7 @@ jobs:
216216
working-directory: ./reflex-web
217217
run: poetry run uv pip install -r requirements.txt
218218
- name: Install additional dependencies for DB access
219-
run: poetry run uv pip install psycopg2-binary
219+
run: poetry run uv pip install psycopg
220220
- name: Init Website for reflex-web
221221
working-directory: ./reflex-web
222222
run: poetry run reflex init

.github/workflows/unit_tests.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
fail-fast: false
2929
matrix:
3030
os: [ubuntu-latest, windows-latest]
31-
python-version: ['3.9.18', '3.10.13', '3.11.5', '3.12.0']
31+
python-version: ['3.9.18', '3.10.13', '3.11.5', '3.12.0', '3.13.0']
3232
# Windows is a bit behind on Python version availability in Github
3333
exclude:
3434
- os: windows-latest
@@ -88,8 +88,9 @@ jobs:
8888
strategy:
8989
fail-fast: false
9090
matrix:
91-
python-version: ['3.9.18', '3.10.13', '3.11.5', '3.12.0']
92-
runs-on: macos-12
91+
# Note: py39, py310 versions chosen due to available arm64 darwin builds.
92+
python-version: ['3.9.13', '3.10.11', '3.11.5', '3.12.0', '3.13.0']
93+
runs-on: macos-latest
9394
steps:
9495
- uses: actions/checkout@v4
9596
- uses: ./.github/actions/setup_build_env

docker-example/production-app-platform/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ FROM python:3.13-slim
5252
WORKDIR /app
5353
RUN adduser --disabled-password --home /app reflex
5454
COPY --chown=reflex --from=init /app /app
55-
# Install libpq-dev for psycopg2 (skip if not using postgres).
55+
# Install libpq-dev for psycopg (skip if not using postgres).
5656
RUN apt-get update -y && apt-get install -y libpq-dev && rm -rf /var/lib/apt/lists/*
5757
USER reflex
5858
ENV PATH="/app/.venv/bin:$PATH" PYTHONUNBUFFERED=1

docker-example/production-compose/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ FROM python:3.13-slim
3939
WORKDIR /app
4040
RUN adduser --disabled-password --home /app reflex
4141
COPY --chown=reflex --from=init /app /app
42-
# Install libpq-dev for psycopg2 (skip if not using postgres).
42+
# Install libpq-dev for psycopg (skip if not using postgres).
4343
RUN apt-get update -y && apt-get install -y libpq-dev && rm -rf /var/lib/apt/lists/*
4444
USER reflex
4545
ENV PATH="/app/.venv/bin:$PATH" PYTHONUNBUFFERED=1

docker-example/production-compose/compose.prod.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ services:
1515

1616
app:
1717
environment:
18-
DB_URL: postgresql+psycopg2://postgres:secret@db/postgres
18+
DB_URL: postgresql+psycopg://postgres:secret@db/postgres
1919
REDIS_URL: redis://redis:6379
2020
depends_on:
2121
- db

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ build-backend = "poetry.core.masonry.api"
8787
[tool.ruff]
8888
target-version = "py39"
8989
lint.isort.split-on-trailing-comma = false
90-
lint.select = ["B", "D", "E", "F", "I", "SIM", "W", "RUF", "FURB"]
90+
lint.select = ["B", "D", "E", "F", "I", "SIM", "W", "RUF", "FURB", "ERA"]
9191
lint.ignore = ["B008", "D205", "E501", "F403", "SIM115", "RUF006", "RUF012"]
9292
lint.pydocstyle.convention = "google"
9393

reflex/.templates/web/utils/state.js

Lines changed: 31 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ export const applyEvent = async (event, socket) => {
300300
if (socket) {
301301
socket.emit(
302302
"event",
303-
JSON.stringify(event, (k, v) => (v === undefined ? null : v))
303+
event,
304304
);
305305
return true;
306306
}
@@ -407,6 +407,8 @@ export const connect = async (
407407
transports: transports,
408408
autoUnref: false,
409409
});
410+
// Ensure undefined fields in events are sent as null instead of removed
411+
socket.current.io.encoder.replacer = (k, v) => (v === undefined ? null : v)
410412

411413
function checkVisibility() {
412414
if (document.visibilityState === "visible") {
@@ -443,8 +445,7 @@ export const connect = async (
443445
});
444446

445447
// On each received message, queue the updates and events.
446-
socket.current.on("event", async (message) => {
447-
const update = JSON5.parse(message);
448+
socket.current.on("event", async (update) => {
448449
for (const substate in update.delta) {
449450
dispatch[substate](update.delta[substate]);
450451
}
@@ -456,7 +457,7 @@ export const connect = async (
456457
});
457458
socket.current.on("reload", async (event) => {
458459
event_processing = false;
459-
queueEvents([...initialEvents(), JSON5.parse(event)], socket);
460+
queueEvents([...initialEvents(), event], socket);
460461
});
461462

462463
document.addEventListener("visibilitychange", checkVisibility);
@@ -497,23 +498,31 @@ export const uploadFiles = async (
497498
// Whenever called, responseText will contain the entire response so far.
498499
const chunks = progressEvent.event.target.responseText.trim().split("\n");
499500
// So only process _new_ chunks beyond resp_idx.
500-
chunks.slice(resp_idx).map((chunk) => {
501-
event_callbacks.map((f, ix) => {
502-
f(chunk)
503-
.then(() => {
504-
if (ix === event_callbacks.length - 1) {
505-
// Mark this chunk as processed.
506-
resp_idx += 1;
507-
}
508-
})
509-
.catch((e) => {
510-
if (progressEvent.progress === 1) {
511-
// Chunk may be incomplete, so only report errors when full response is available.
512-
console.log("Error parsing chunk", chunk, e);
513-
}
514-
return;
515-
});
516-
});
501+
chunks.slice(resp_idx).map((chunk_json) => {
502+
try {
503+
const chunk = JSON5.parse(chunk_json);
504+
event_callbacks.map((f, ix) => {
505+
f(chunk)
506+
.then(() => {
507+
if (ix === event_callbacks.length - 1) {
508+
// Mark this chunk as processed.
509+
resp_idx += 1;
510+
}
511+
})
512+
.catch((e) => {
513+
if (progressEvent.progress === 1) {
514+
// Chunk may be incomplete, so only report errors when full response is available.
515+
console.log("Error processing chunk", chunk, e);
516+
}
517+
return;
518+
});
519+
});
520+
} catch (e) {
521+
if (progressEvent.progress === 1) {
522+
console.log("Error parsing chunk", chunk_json, e);
523+
}
524+
return;
525+
}
517526
});
518527
};
519528

@@ -799,7 +808,7 @@ export const useEventLoop = (
799808
connect(
800809
socket,
801810
dispatch,
802-
["websocket", "polling"],
811+
["websocket"],
803812
setConnectErrors,
804813
client_storage
805814
);

0 commit comments

Comments
 (0)