Conversation
- add vitest - add stream buffer for exact byte count reading from ReadableStream
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the
✨ Finishing touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Greptile SummaryThis PR introduces a custom streaming Git packfile parser as the foundation for a hybrid R2 + D1 storage architecture. The parser handles packfile header parsing, object decompression, delta objects (both OFS and REF types), and SHA-1 checksum verification. Key Changes:
Issues Found:
Confidence Score: 3/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant Client as Git Client
participant Worker as Cloudflare Worker
participant Cache as Cache API
participant DO as Durable Object (SQLite)
participant R2 as R2 Storage
participant Parser as PackfileParser
Client->>Worker: git clone/fetch request
Worker->>Cache: Check for parsed commit/tree
alt Cache Hit
Cache-->>Worker: Return parsed object
Worker-->>Client: Send object
else Cache Miss
Worker->>DO: Query object index (oid→pack_id, offset)
DO-->>Worker: Return pack location
Worker->>R2: Range request for object at offset
R2-->>Worker: Stream compressed packfile chunk
Worker->>Parser: Create PackfileParser(stream)
Parser->>Parser: parseHeader() - validate signature
Parser->>Parser: parseObject() - read type/size
Parser->>Parser: decompressObject() - inflate zlib
Parser->>Parser: Verify SHA-1 checksum
Parser-->>Worker: Return parsed object
Worker->>Cache: Store parsed object (1 year TTL)
Worker-->>Client: Send object
end
Note over Parser: StreamBuffer manages chunks<br/>Memory-efficient compaction<br/>Delayed hash computation
|
| if ( | ||
| this.buffer.bytesRead + bufferSize >= | ||
| this._progress.bytesRead + bufferSize * 2 | ||
| ) { | ||
| return Result.err( | ||
| err instanceof Error ? err : new Error(String(err)) | ||
| ); | ||
| } |
There was a problem hiding this comment.
logic: the condition logic is incorrect - this.buffer.bytesRead should equal this._progress.bytesRead since they're synchronized (lines 92, 104, 150), making this condition effectively bufferSize >= bufferSize * 2, which is only true when bufferSize <= 0
this means the error branch will almost never execute, and decompression will always retry up to maxAttempts even when more data won't help
| if ( | |
| this.buffer.bytesRead + bufferSize >= | |
| this._progress.bytesRead + bufferSize * 2 | |
| ) { | |
| return Result.err( | |
| err instanceof Error ? err : new Error(String(err)) | |
| ); | |
| } | |
| if (this.done && available.length < bufferSize) { | |
| return Result.err( | |
| err instanceof Error ? err : new Error(String(err)) | |
| ); | |
| } |
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/web/src/git/pack/index.ts
Line: 366:373
Comment:
**logic:** the condition logic is incorrect - `this.buffer.bytesRead` should equal `this._progress.bytesRead` since they're synchronized (lines 92, 104, 150), making this condition effectively `bufferSize >= bufferSize * 2`, which is only true when `bufferSize <= 0`
this means the error branch will almost never execute, and decompression will always retry up to `maxAttempts` even when more data won't help
```suggestion
if (this.done && available.length < bufferSize) {
return Result.err(
err instanceof Error ? err : new Error(String(err))
);
}
```
How can I resolve this? If you propose a fix, please make it concise.store git packs, objects, and refs in SQLite-backed DO enabling faster browsing of commits, trees, and blobs - schema: git_packs, git_object_index, git_refs tables - drizzle migrations for DO with sql loader vite plugin - test button on dashboard for verification
Removes ~150 lines of custom error class implementation by adopting the better-result package, reducing maintenance burden. Also adds node_modules exclusion to tsconfigs to fix IDE performance.
enables offloading large pack files to R2 object storage, allowing repos to exceed Durable Object size limits
Users now see real-time progress during git push instead of silent waiting. Packfiles stored in R2 enabling larger repo support beyond DO SQLite limits. Temporarily disabled while migrating: - git clone/fetch (upload-pack returns 501) - repo browsing UI (shows placeholder data) BREAKING CHANGE: git clone/fetch unavailable until upload-pack implemented
This PR rewrites the whole git backend to support R2 + D1 Hybrid Architecture