Skip to content

Enhanced logging for parameter query results#520

Merged
Sleepful merged 2 commits intopowersync-ja:mainfrom
Sleepful:jv-param-query-logging
Feb 23, 2026
Merged

Enhanced logging for parameter query results#520
Sleepful merged 2 commits intopowersync-ja:mainfrom
Sleepful:jv-param-query-logging

Conversation

@Sleepful
Copy link
Contributor

Summary

Adds detailed logging for parameter query results to improve debugging when the configured limit is exceeded. Users currently only see a generic PSYNC_S2305 error with no breakdown of which sync stream definitions are contributing.

Based on #462 by @hamzzy, rebased onto current main with review feedback addressed.

Changes

Original work (hamzzy)

  • Track parameter query results per sync stream definition (before deduplication)
  • Add total param_results count to checkpoint log messages and structured log data
  • Add per-definition breakdown to PSYNC_S2305 error messages (top 10, sorted by count)
  • 3 new tests: dynamic bucket logging, error breakdown on limit exceeded, top-10 truncation

Review fixes
Addresses feedback from @rkistner on #462:

  • Extract checkpoint log message construction into computeTotalParamResults() + logCheckpoint() helpers
  • Extract error message breakdown into formatParameterQueryBreakdown() helper
  • Log remaining result count (not just definition count) when truncating to top 10: "... and N more results from M definitions"
  • Fix test types to match current API (JwtPayload constructor, .config.hydrate())

Packages affected (patch)

  • @powersync/service-core

@changeset-bot
Copy link

changeset-bot bot commented Feb 20, 2026

🦋 Changeset detected

Latest commit: 04484d1

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 12 packages
Name Type
@powersync/service-core Patch
@powersync/service-core-tests Patch
@powersync/service-module-core Patch
@powersync/service-module-mongodb-storage Patch
@powersync/service-module-mongodb Patch
@powersync/service-module-mssql Patch
@powersync/service-module-mysql Patch
@powersync/service-module-postgres-storage Patch
@powersync/service-module-postgres Patch
@powersync/service-image Patch
test-client Patch
@powersync/service-schema Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@Sleepful
Copy link
Contributor Author

Sleepful commented Feb 20, 2026

I found it convenient to look at the diff between the two branches and scrolling to the test file packages/service-core/test/src/sync/BucketChecksumState.test.ts to validate that it remains faithful to the original:

hamzzy/powersync-service@feat/trick-debug-param-query...Sleepful:powersync-service:jv-param-query-logging

Edit: Oh um nevermind, this github diff is too noisy, here is the actual git diff that I wanted to show (keeps same test file with rebase modifications):

git fetch https://github.com/Sleepful/powersync-service.git jv-param-query-logging

git diff 3c9fa253 c4352c40 -- packages/service-core/test/src/sync/BucketChecksumState.test.ts
diff --git a/packages/service-core/test/src/sync/BucketChecksumState.test.ts b/packages/service-core/test/src/sync/BucketChecksumState.test.ts
index 8dd177c61f..f706bc018a 100644
--- a/packages/service-core/test/src/sync/BucketChecksumState.test.ts
+++ b/packages/service-core/test/src/sync/BucketChecksumState.test.ts
@@ -849,7 +849,7 @@
 
       const state = new BucketChecksumState({
         syncContext,
-        tokenPayload: { sub: 'u1' },
+        tokenPayload: new JwtPayload({ sub: 'u1' }),
         syncRequest,
         syncRules: SYNC_RULES_DYNAMIC,
         bucketStorage: storage,
@@ -884,7 +884,7 @@
     data: []
     `,
         { defaultSchema: 'public' }
-      ).hydrate({ hydrationState: versionedHydrationState(4) });
+      ).config.hydrate({ hydrationState: versionedHydrationState(4) });
 
       const storage = new MockBucketChecksumStateStorage();
 
@@ -908,7 +908,7 @@
 
       const state = new BucketChecksumState({
         syncContext: smallContext,
-        tokenPayload: { sub: 'u1' },
+        tokenPayload: new JwtPayload({ sub: 'u1' }),
         syncRequest,
         syncRules: SYNC_RULES_MULTI,
         bucketStorage: storage,
@@ -971,7 +971,7 @@
         yamlDefinitions += `    data: []\n`;
       }
 
-      const SYNC_RULES_MANY = SqlSyncRules.fromYaml(yamlDefinitions, { defaultSchema: 'public' }).hydrate({
+      const SYNC_RULES_MANY = SqlSyncRules.fromYaml(yamlDefinitions, { defaultSchema: 'public' }).config.hydrate({
         hydrationState: versionedHydrationState(5)
       });
 
@@ -995,7 +995,7 @@
 
       const state = new BucketChecksumState({
         syncContext: smallContext,
-        tokenPayload: { sub: 'u1' },
+        tokenPayload: new JwtPayload({ sub: 'u1' }),
         syncRequest,
         syncRules: SYNC_RULES_MANY,
         bucketStorage: storage,
@@ -1020,7 +1020,7 @@
 
       // Verify only top 10 are shown
       const errorMessage = errorMessages[0];
-      expect(errorMessage).toContain('... and 5 more');
+      expect(errorMessage).toContain('... and 5 more results from 5 definitions');
 
       // Count how many definitions are listed (should be exactly 10)
       const defMatches = errorMessage.match(/def\d+:/g);

hamzzy and others added 2 commits February 20, 2026 12:23
- Extract checkpoint log message to helper function
- Extract error message generation to helper function
- Log remaining result count (not definition count) when truncating top 10
- Fix test types to match current API (JwtPayload, config.hydrate)
@Sleepful Sleepful force-pushed the jv-param-query-logging branch from c4352c4 to 04484d1 Compare February 20, 2026 18:23
@Sleepful
Copy link
Contributor Author

Sleepful commented Feb 20, 2026

Rebased with main

@Sleepful Sleepful merged commit b440093 into powersync-ja:main Feb 23, 2026
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants