Skip to content

feat: VmServiceProxy (for intercepting reloadSources) - #5022

Merged
nielsenko merged 11 commits into
serverpod:mainfrom
nielsenko:feat-vm-proxy
May 4, 2026
Merged

nielsenko merged 11 commits into
serverpod:mainfrom
nielsenko:feat-vm-proxy

Conversation

@nielsenko

Copy link
Copy Markdown
Collaborator

This PR is an alternative to #dap. It achieves the same intercept on reloadSources that is needed to work-around dart-lang/sdk#62822.

Where each design wins

Custom adapter wins on

  • Hot restart UX (no reconnect blip)
  • DAP-level extensibility (room to add custom requests later)

Proxy wins on

  • Code volume (~3-4× less)
  • Editor portability (no per-editor adapter wiring)
  • Failure-mode count (smaller transport surface, fewer races)
  • Conceptual cleanliness (the FES owner is the reload responder; no relay through the pod)
  • Long-term maintenance (no package:dds/src/... implementation import, no stdio fallback, no announcement protocol, no vendored sdk code)

Questions

  1. Is hot restart seamless-ness worth the architectural cost? The custom adapter's only material advantage is keeping the DAP session alive across restart.
  2. Is a serverpod debug adapter a feature or a tax?

@nielsenko nielsenko self-assigned this Apr 30, 2026
@nielsenko
nielsenko force-pushed the feat-vm-proxy branch 6 times, most recently from a471951 to 52d6247 Compare May 1, 2026 15:18
@nielsenko
nielsenko marked this pull request as ready for review May 4, 2026 10:10
@nielsenko
nielsenko force-pushed the feat-vm-proxy branch 2 times, most recently from 216eeb5 to 5a3d16d Compare May 4, 2026 13:49

@marcelomendoncasoares marcelomendoncasoares left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! 🚀

Only one question regarding a related PR.

nielsenko added 7 commits May 4, 2026 20:07
…tion

The pod's --write-service-info now lands at vm-service-info.pod.json; the
user-facing vm-service-info.json gets the proxy's URI, so an IDE attaching
via the standard Dart attach config hits the proxy instead. The proxy
intercepts reloadSources and routes it through WatchSession.forceReload
(codegen + hooks + compile + reload) instead of the VM's built-in
reloadSources, which crashes kernel_service when the isolate was booted
from a precompiled dill.

The proxy is retargeted (not rebuilt) on pod restart so the published URI
stays stable across the swap.
Replaces the direct `dart bin/main.dart` launch with `serverpod start --watch --no-tui` driven by a background task, then attaches Dart-Code to the proxy's vm-service-info.json. The compound that brings up server + flutter still works the same way.

Drops the docker_compose_up task; serverpod start brings up Docker itself when a docker-compose.yaml is present.

Anchors the matcher's endsPattern to a comment at the source log line so a future rewording can't break the task->launch handoff silently.
_mountOrRetargetProxy now logs a warning and returns the existing
proxy (or null) instead of throwing when the pod's vmServiceUri is
null. The watch loop, codegen, MCP socket, and TUI keep running;
only IDE-attach is unavailable for that pod.

Bumps the VM service info-file poll timeout from 5s to 30s and adds
a debug log of the resolved file path so a slow first boot doesn't
get misdiagnosed as a missing file. The timeout warning now names
the path and lists the most likely causes.
If a server is already running and reachable via the user-facing
vm-service-info.json, both the CLI and TUI watch paths now log the
existing URI and exit with code 0 instead of trying to bind another
pod / proxy on top. Stale info files are cleaned up by
_checkExistingServer.

Drops the now-redundant 'projectname_server (attach only)' entry from
the template launch.json: the primary config's preLaunchTask is safe
to run when the server is already up.

The existing-server log emits the same 'VM service proxy listening on'
prefix a fresh start would emit so the task's problemMatcher fires
either way.
@nielsenko
nielsenko force-pushed the feat-vm-proxy branch 2 times, most recently from cb86163 to 8ba5241 Compare May 4, 2026 20:09
nielsenko added 4 commits May 4, 2026 22:46
WebSocket close reasons are capped at 123 bytes per RFC 6455
- calls applyPendingMigrations once per boot
- drops the now-redundant '-- --apply-migrations' arg from tasks.json
@nielsenko
nielsenko merged commit 7c8ef02 into serverpod:main May 4, 2026
83 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators May 4, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Replace the IDE server launch command to use serverpod start

2 participants