Skip to content

Commit 2feb679

Browse files
authored
Merge pull request #95 from powersync-ja/bugfix-unitialized-tag
Fix uninitialized tag
2 parents 2eb566a + b8dfc98 commit 2feb679

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

.changeset/olive-spoons-stare.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@powersync/service-core': patch
3+
---
4+
5+
Moved tag variable initialization in diagnostics route to ensure it is initialized before usage

packages/service-core/src/api/diagnostics.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ export async function getSyncRulesStatus(
5353
};
5454
}
5555

56+
const sourceConfig = await apiHandler.getSourceConfig();
57+
// This method can run under some situations if no connection is configured yet.
58+
// It will return a default tag in such a case. This default tag is not module specific.
59+
const tag = sourceConfig.tag ?? DEFAULT_TAG;
5660
const systemStorage = live_status ? bucketStorage.getInstance(sync_rules) : undefined;
5761
const status = await systemStorage?.getStatus();
5862
let replication_lag_bytes: number | undefined = undefined;
@@ -128,15 +132,12 @@ export async function getSyncRulesStatus(
128132
})
129133
);
130134

131-
const sourceConfig = await apiHandler.getSourceConfig();
132-
const tag = sourceConfig.tag ?? DEFAULT_TAG;
133-
134135
return {
135136
content: include_content ? sync_rules.sync_rules_content : undefined,
136137
connections: [
137138
{
138139
id: sourceConfig.id ?? DEFAULT_DATASOURCE_ID,
139-
tag: sourceConfig.tag ?? DEFAULT_TAG,
140+
tag: tag,
140141
slot_name: sync_rules.slot_name,
141142
initial_replication_done: status?.snapshot_done ?? false,
142143
// TODO: Rename?

0 commit comments

Comments
 (0)