You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: startAtOperationTime not set when resumeAfter is null
Bug: openChangeStream() checked streamOptions.startAtOperationTime
(always undefined — constructed without it) instead of startAfter
(the local variable with the parsed timestamp). This made the else-if
branch dead code — startAtOperationTime was never set when resumeAfter
was null.
This broke the legacy resume path where the stored LSN has no resume
token (only a hex timestamp from keepalive/snapshot). Without
startAtOperationTime, the stream opened from "now" instead of the
stored position, potentially missing the initial checkpoint event
and causing batch.commit() to never be called.
Introduced in fdf840c (feat: implement Cosmos DB workarounds).
Found by binary search: passes at bd3170c (auth fix), fails at
f6ba463 (scaffolding), root cause in the openChangeStream refactor.
Also reverted tsconfig.base.json target from ES2024 back to esnext
(the ES2024 change was a workaround for Node 22 not supporting native
await using — CI uses Node 24 which does).
|`COSMOS_DB_TEST`| Yes | Set to `true` to enable Cosmos DB integration tests. Without this, all tests in `cosmosdb_mode.test.ts` are skipped. |
16
+
|`MONGO_TEST_DATA_URL`| Yes | Cosmos DB connection URI. Must include a database name in the path (see below). |
17
+
|`PG_STORAGE_TEST_URL`| No | PostgreSQL connection for PowerSync storage. Defaults to `postgres://postgres:postgres@localhost:5432/powersync_storage_test`. |
18
+
|`TEST_MONGO_STORAGE`| No | Set to `false` to skip MongoDB storage tests. Recommended when testing against Cosmos DB to avoid using it as a storage backend. |
19
+
20
+
### Connection URI format
21
+
22
+
The `MONGO_TEST_DATA_URL` must include a database name in the path. Cosmos DB URIs typically don't have one, so you need to add it before the query string:
If your password contains special characters (`=`, `@`, `+`, `/`), they must be URL-encoded in the URI (e.g., `=` becomes `%3D`). Cosmos DB auto-generated passwords often contain `=` (base64).
33
+
34
+
## Commands
35
+
36
+
All commands run from the module directory: `modules/module-mongodb/`
37
+
38
+
```bash
39
+
# Run all Cosmos DB tests (integration + unit helpers):
|`cosmosdb_helpers.test.ts`| No (1 test needs MongoDB) | Unit tests: `getEventTimestamp`, sentinel parsing/matching, detection logic. Runs against any MongoDB or standalone. |
| basic replication | Insert, update, delete through change stream with wallTime timestamps |
83
+
| sentinel checkpoint | Checkpoint created with `mode: 'sentinel'`, resolved by matching document content in the stream |
84
+
| keepalive | Stream idles past the keepalive interval without crashing on Cosmos DB resume tokens |
85
+
| write checkpoint | Full `createReplicationHead` → sentinel → polling flow for client write consistency |
86
+
| resume after restart | Stop streaming, create new context, resume from stored token |
87
+
88
+
## Known Issues
89
+
90
+
-**Resume on storage v2**: The "resume after restart" test intermittently fails on storage v2 only (v1 and v3 pass). This appears to be a storage-version-specific issue, not a Cosmos DB detection or resume token problem.
0 commit comments