Skip to content

fix(THU-537): advertise host-reachable PowerSync URL in local docker-compose#982

Open
darkbanjo wants to merge 1 commit into
mainfrom
jkab/thu-537-local-docker-compose-advertises-docker-internal-powersync
Open

fix(THU-537): advertise host-reachable PowerSync URL in local docker-compose#982
darkbanjo wants to merge 1 commit into
mainfrom
jkab/thu-537-local-docker-compose-advertises-docker-internal-powersync

Conversation

@darkbanjo

@darkbanjo darkbanjo commented Jun 12, 2026

Copy link
Copy Markdown
Collaborator

Problem

In the local deploy/docker-compose.yml stack, Cloud Sync never establishes — the panel sits on "Changes will sync when back online".

POWERSYNC_URL was set to the internal Docker hostname http://powersync:8080. The backend echoes that value back to the browser in /v1/powersync/token (backend/src/api/powersync.ts), and the frontend SharedWorker then tries to connect to http://powersync:8080/... — which only resolves inside the Docker network. Browser DNS fails silently → SharedWorker stays offline.

Fix

Point POWERSYNC_URL at the host-reachable URL via the existing port mapping:

POWERSYNC_URL: http://localhost:${POWERSYNC_PORT:-8080}

(powersync already maps ${POWERSYNC_PORT:-8080}:8080 to the host.) Added a comment contrasting this with OIDC_DISCOVERY_URL right above it, which intentionally does use the internal hostname (backend-only, never sent to the browser).

Note vs. ticket

The ticket suggested port 8081, but the actual host mapping in this file defaults to 8080 (${POWERSYNC_PORT:-8080}:8080). Used 8080 to match the real mapping — 8081 would point at nothing.

Testing

Config-only. With this change the backend advertises http://localhost:8080, which the browser can reach, so the SharedWorker connects. (Out of scope: preview-env PowerSync architecture — separate/larger issue.)

🤖 Generated with Claude Code


Note

Low Risk
Single local dev compose env change with no application code or production config impact.

Overview
Fixes local Docker Cloud Sync staying offline by changing backend POWERSYNC_URL from the internal service URL (http://powersync:8080) to http://localhost:${POWERSYNC_PORT:-8080}, matching the published host port on the powersync service.

That value is returned to the browser (e.g. /v1/powersync/token), so the client must use a host-resolvable URL—not a Docker-only hostname. A short comment was added next to the env var to contrast this with OIDC_DISCOVERY_URL, which correctly stays on an internal hostname because only the backend uses it.

Reviewed by Cursor Bugbot for commit cd0615e. Bugbot is set up for automated code reviews on this repo. Configure here.

- POWERSYNC_URL is echoed to the browser in the /v1/powersync/token
  response, so the internal `powersync:8080` Docker hostname can't
  resolve there and leaves the SharedWorker stuck offline
- Use the host port mapping (localhost:POWERSYNC_PORT) instead
@github-actions

Copy link
Copy Markdown

Semgrep Security Scan

No security issues found.

@github-actions

Copy link
Copy Markdown

Preview environment deployed 🚀

Service URL
Marketing / blog / docs https://thunderbolt-pr-982.preview.thunderbolt.io
App https://app-pr-982.preview.thunderbolt.io
API https://api-pr-982.preview.thunderbolt.io
Keycloak https://auth-pr-982.preview.thunderbolt.io
PowerSync https://powersync-pr-982.preview.thunderbolt.io

Stack: preview-pr-982 · Commit: cd0615e56958e1316fc9ce7bc45c5bca418400fc

Auto-destroys on PR close/merge. Login via the bundled Keycloak realm — demo@thunderbolt.io / demo by default.

@github-actions

Copy link
Copy Markdown

PR Metrics

Metric Value
Lines changed (prod code) +5 / -1
JS bundle size (gzipped) 🟢 737.6 KB → 737.4 KB (-199 B, -0.0%)
Test coverage 🟢 78.13% → 78.13% (+0.0%)
Performance (preview) Preview not ready — Render deploy may have timed out
Accessibility
Best Practices
SEO

Updated Fri, 12 Jun 2026 19:35:22 GMT · run #1881

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.

1 participant