Skip to content

Commit 70d5815

Browse files
zshannonclaude
andcommitted
Fix S3 module resolution and add debugging
- Normalize version parameter to handle both with/without trailing slash - Add comprehensive S3 access logging for debugging - Fixed cache key construction to avoid double slashes - Tested locally with React imports - typecheck and build working 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent da10d51 commit 70d5815

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

.env.op

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# S3 upload configuration for TypeScript server
2+
AWS_ACCESS_KEY_ID="op://Crayon Production/FLY_TSGO_TIGRIS/AWS_ACCESS_KEY_ID"
3+
AWS_SECRET_ACCESS_KEY="op://Crayon Production/FLY_TSGO_TIGRIS/AWS_SECRET_ACCESS_KEY"
4+
AWS_REGION="op://Crayon Production/FLY_TSGO_TIGRIS/AWS_REGION"
5+
AWS_ENDPOINT_URL_S3="op://Crayon Production/FLY_TSGO_TIGRIS/AWS_ENDPOINT_URL_S3"
6+
S3_BUCKET="op://Crayon Production/FLY_TSGO_TIGRIS/S3_BUCKET"

server/server.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,14 @@ func newS3FS(version string) *s3FS {
104104

105105
// getFromCache retrieves an entry from cache or fetches from S3
106106
func getFromCache(ctx context.Context, version, path string) *CacheEntry {
107-
cacheKey := fmt.Sprintf("%s%s", version, path)
107+
// Normalize version - ensure it ends with exactly one slash
108+
if !strings.HasSuffix(version, "/") {
109+
version = version + "/"
110+
}
111+
cacheKey := fmt.Sprintf("%s%s", version, strings.TrimPrefix(path, "/"))
112+
113+
// Log S3 access for debugging
114+
log.Printf("S3 lookup: bucket=%s, key=%s", s3Bucket, cacheKey)
108115

109116
// Check cache first
110117
cacheMutex.RLock()
@@ -129,6 +136,7 @@ func getFromCache(ctx context.Context, version, path string) *CacheEntry {
129136
defer result.Body.Close()
130137
content, err := io.ReadAll(result.Body)
131138
if err == nil {
139+
log.Printf("S3 file found: %s (%d bytes)", cacheKey, len(content))
132140
entry := &CacheEntry{
133141
Exists: true,
134142
IsFile: true,
@@ -138,7 +146,11 @@ func getFromCache(ctx context.Context, version, path string) *CacheEntry {
138146
cache.Add(cacheKey, entry)
139147
cacheMutex.Unlock()
140148
return entry
149+
} else {
150+
log.Printf("S3 file read error for %s: %v", cacheKey, err)
141151
}
152+
} else {
153+
log.Printf("S3 file fetch error for %s: %v", cacheKey, err)
142154
}
143155

144156
// Not a file, try as directory
@@ -157,6 +169,7 @@ func getFromCache(ctx context.Context, version, path string) *CacheEntry {
157169

158170
if err != nil {
159171
s3ListErrors.Inc()
172+
log.Printf("S3 list error for key %s: %v", cacheKey, err)
160173
// Cache as non-existent
161174
entry := &CacheEntry{Exists: false}
162175
cacheMutex.Lock()

0 commit comments

Comments
 (0)