Skip to content

Fix/touched tables + improvements to dev#18

Merged
digitalmio merged 4 commits into
mainfrom
fix/touched-tables
May 17, 2026
Merged

Fix/touched tables + improvements to dev#18
digitalmio merged 4 commits into
mainfrom
fix/touched-tables

Conversation

@digitalmio
Copy link
Copy Markdown
Owner

No description provided.

packages/cli/src/commands/dev.ts:
- Make cleanup() synchronous since watcher.close() is fire-and-forget
- Suppress watcher.close() errors with .catch()

packages/client/src/vite.ts:
- Restrict plugin to serve mode with apply: "serve"
- Change stdio from "inherit" to ["ignore", "pipe", "pipe"]
- Pipe subprocess stdout/stderr explicitly to process streams
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 17, 2026

Greptile Summary

This PR fixes the client invalidation metadata to include both read and changed ("touched") tables, and improves the dev tooling in several ways.

  • Server (index.ts): _meta.t now hashes the union of result.meta.read and result.meta.changed (deduplicated), so the client can invalidate all tables touched by a mutation, not just the ones that were queried.
  • CLI (dev.ts): cleanup() is made synchronous; watcher.close() is fire-and-forget to avoid blocking the process on teardown.
  • Vite plugin (vite.ts): apply: \"serve\" restricts the plugin to dev mode only; stdio is changed from \"inherit\" to explicit pipe so the child process output can be intercepted if needed.
  • Generator (generate.ts): indentJson helper added to fix the previously-reported malformed indentation of the journal block in the auto-generated index.ts.

Confidence Score: 5/5

Safe to merge — all changes are additive or fix previously reported bugs with no regressions on the critical RPC path.

The RPC metadata fix is a straightforward union+deduplicate that is strictly more correct than the previous read-only approach. The dev-tooling changes (sync cleanup, stdio piping, apply:serve) are isolated to the CLI and Vite plugin and do not affect production runtime behaviour. The indentation fix in the generator corrects a previously flagged output bug.

No files require special attention; packages/cli/src/commands/dev.ts has a minor cosmetic edge case around the force-kill timer on the error-exit path.

Important Files Changed

Filename Overview
packages/cli/src/commands/dev.ts cleanup() made synchronous; watcher.close() is now fire-and-forget. Minor: forceKillAfterTimeout is orphaned on the error-exit path.
packages/cli/src/migrations/generate.ts Added indentJson helper to fix previously-reported indentation bug in the generated index.ts; migration key indentation corrected from 2 to 4 spaces.
packages/client/src/vite.ts apply: "serve" added to prevent the plugin running during builds; stdio changed from "inherit" to explicit pipe so output is controllable.
packages/server/src/server/index.ts _meta.t now includes both read and changed tables (deduplicated via Set) so the client can invalidate all touched tables after a mutation.
playground/edgepod/.generated/migrations/meta/_journal.json Reformatted to compact JSON; the generator still writes pretty-printed JSON so this will be normalised on the next migration run.
playground/edgepod/.generated/migrations/snapshot.json id/prevId UUIDs updated to reflect the new migration chain; change is expected and correct.

Sequence Diagram

sequenceDiagram
    participant C as Client
    participant S as edgePodFetch (Worker)
    participant DO as Durable Object

    C->>S: POST /rpc/functionName
    S->>DO: executeRpc(functionName, args, rpcCtx)
    DO-->>S: success, data, meta read and changed arrays
    S->>S: dedupe read and changed via Set
    S->>S: hashMetaTableNames(deduped)
    S-->>C: success, data, _meta t hashedTables, warnings
Loading

Reviews (3): Last reviewed commit: "Fix indentation in generated migrations ..." | Re-trigger Greptile

Comment thread packages/server/src/server/index.ts Outdated
Comment thread playground/edgepod/.generated/migrations/index.ts
Use a `Set` to remove duplicates from the combined read and changed
table names before hashing, preventing redundant entries in the
metadata.
Add `indentJson` helper to properly indent nested JSON objects in the
generated migrations index, ensuring 2-space indentation for the journal
object and 4-space indentation for migration entries.
@digitalmio digitalmio merged commit 16c9d0d into main May 17, 2026
4 checks passed
@digitalmio digitalmio deleted the fix/touched-tables branch May 17, 2026 17:24
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