Skip to content

revert: normalize Drizzle schema paths for Windows compatibility (#75) - #76

Merged
cpojer merged 1 commit into
mainfrom
revert-75
Apr 3, 2026
Merged

cpojer merged 1 commit into
mainfrom
revert-75

Conversation

@shulaoda

@shulaoda shulaoda commented Apr 3, 2026

Copy link
Copy Markdown
Member

Summary

Reverts #75.

The original fix normalized schema.path in discoverSchema() and used posix.join for @schema alias resolution. While the approach was correct for module IDs returned from resolveId, it didn't account for the broader impact:

  • Vite's file watcher emits native OS paths (backslashes on Windows), so normalizing stored paths to forward slashes breaks startsWith / === comparisons in watcher callbacks
  • The same path inconsistency affects plugin-routing.ts directory variables (routesDir, middlewareDir, etc.) which are used for both watcher comparisons and module ID generation
  • A proper fix needs to normalize paths consistently across the entire plugin surface — including watcher entry points, process.cwd() root, all path.join results used as module IDs, and fileURLToPath results — rather than patching individual call sites

Will follow up with a comprehensive fix that addresses the full scope.

@shulaoda
shulaoda requested a review from cpojer April 3, 2026 07:59
@cpojer
cpojer merged commit 1844b72 into main Apr 3, 2026
6 checks passed
@cpojer
cpojer deleted the revert-75 branch April 3, 2026 08:03
cpojer pushed a commit that referenced this pull request Sep 11, 2026
…fP (#76)

The bug is in the **preflight endpoint** at `packages/api/src/routes/deploy.ts`. It handles the WfP→anything case but **misses the static→WfP case**.

```
CLI                                    API                               CF Asset API
 │                                      │                                    │
 │  1. preflight(assetManifest)         │                                    │
 │─────────────────────────────────────>│                                    │
 │                                      │  checks previous deploy:           │
 │                                      │  has serving manifest? YES (was    │
 │                                      │  static) → compares hashes         │
 │  2. { needed: [1], skipped: 29 }     │                                    │
 │<─────────────────────────────────────│                                    │
 │                                      │                                    │
 │  3. deploy(FormData with 1 asset)    │                                    │
 │─────────────────────────────────────>│                                    │
 │                                      │  collectAssets → assetsByHash      │
 │                                      │  has 1 entry                       │
 │                                      │                                    │
 │                                      │  fills manifest with 29 skipped    │
 │                                      │  hashes from previous deploy       │
 │                                      │                                    │
 │                                      │  createAssetUploadSession(         │
 │                                      │    30-entry manifest)              │
 │                                      │───────────────────────────────────>│
 │                                      │                                    │
 │                                      │  buckets: [29 hashes]              │
 │                                      │  (CF never had these — they were   │
 │                                      │   in KV/R2, not CF asset store!)   │
 │                                      │<───────────────────────────────────│
 │                                      │                                    │
 │                                      │  uploadAssetBuckets():             │
 │                                      │  assetsByHash.get(hash) → null!    │
 │                                      │  ═══════ BOOM ═══════              │
 │                                      │  AssetHashMissError                │
```

The design doc states:

> Since carried-forward assets already exist in CF's storage, CF won't request them — so we don't need the actual file contents for those.

This assumption is correct for same-type deploys but **wrong when crossing storage mechanisms**:

| Transition | Previous assets in | New assets go to | Dedup safe? |
|---|---|---|---|
| static→static | KV/R2 | KV/R2 | Yes |
| WfP→WfP | CF Asset API | CF Asset API | Yes (currently forced all-fresh) |
| WfP→static | CF Asset API | KV/R2 | Yes (forced all-fresh by existing check) |
| **static→WfP** | **KV/R2** | **CF Asset API** | **NO — this is the bug** |

The existing code only checks the reverse direction:

```ts
// Handles WfP→anything: no serving manifest means previous was WfP → all fresh
if (!hasServingManifest) {
  return c.json({ needed: Object.keys(assetManifest), total, skipped: 0 });
}
```

The CLI now sends `hasWorker: true` in the preflight body for full/framework
deploys. The preflight endpoint checks: if previous was static (has serving
manifest) AND current has a worker, all assets are returned as needed to force
a fresh upload to CF's asset API. Static-to-static dedup remains unaffected.

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.

2 participants