Skip to content

Commit 3834477

Browse files
committed
debug(e2e): add diagnostics for warmServer artifact 404
- prepare script: verify ppk.patch and apk.patch exist after generation - server: log 404 responses with resolved path and existence check - server: add /debug/artifacts endpoint listing all files - globalSetup: capture server stdout/stderr to .server.log - globalSetup: list artifacts dir and query debug endpoint before warmServer
1 parent 47110ed commit 3834477

3 files changed

Lines changed: 54 additions & 3 deletions

File tree

‎Example/e2etest/e2e/globalSetup.ts‎

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,17 +97,21 @@ function startServer() {
9797
const serverScript = path.join(projectRoot, 'scripts/local-e2e-server.ts');
9898
fs.mkdirSync(artifactsRoot, { recursive: true });
9999

100+
const logFile = path.join(artifactsRoot, '.server.log');
101+
const logFd = fs.openSync(logFile, 'w');
102+
100103
const child = spawn('bun', [serverScript], {
101104
cwd: projectRoot,
102105
detached: true,
103-
stdio: 'ignore',
106+
stdio: ['ignore', logFd, logFd],
104107
env: {
105108
...process.env,
106109
E2E_ASSET_PORT: String(LOCAL_UPDATE_PORT),
107110
},
108111
});
109112
child.unref();
110113
fs.writeFileSync(pidFile, String(child.pid));
114+
// Keep logFd open for the server lifetime — it will be cleaned up on process exit.
111115
}
112116

113117
function waitForServer(timeoutMs = 30000) {
@@ -235,6 +239,27 @@ async function globalSetup() {
235239
}
236240
startServer();
237241
await waitForServer();
242+
243+
// Diagnostic: list artifacts via debug endpoint and local filesystem
244+
const origin = `http://127.0.0.1:${LOCAL_UPDATE_PORT}`;
245+
try {
246+
const debugRes = await fetch(`${origin}/debug/artifacts`);
247+
if (debugRes.ok) {
248+
console.log('[globalSetup] Server artifacts:', await debugRes.text());
249+
} else {
250+
console.log('[globalSetup] Debug endpoint returned:', debugRes.status);
251+
}
252+
} catch (e) {
253+
console.log('[globalSetup] Debug endpoint error:', e);
254+
}
255+
const localArtifactsDir = path.join(artifactsRoot, platform);
256+
if (fs.existsSync(localArtifactsDir)) {
257+
const files = fs.readdirSync(localArtifactsDir);
258+
console.log(`[globalSetup] Local artifacts dir (${localArtifactsDir}):`, files);
259+
} else {
260+
console.log(`[globalSetup] Local artifacts dir MISSING: ${localArtifactsDir}`);
261+
}
262+
238263
await warmServer(platform as 'ios' | 'android');
239264
await detoxGlobalSetup();
240265
}

‎Example/e2etest/scripts/local-e2e-server.ts‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,9 @@ const server = Bun.serve({
140140
!fs.existsSync(filePath) ||
141141
fs.statSync(filePath).isDirectory()
142142
) {
143+
console.error(
144+
`[404] ${url.pathname} -> ${filePath} (exists: ${filePath ? fs.existsSync(filePath) : 'null'})`,
145+
);
143146
return new Response('not found', { status: 404 });
144147
}
145148

@@ -156,6 +159,22 @@ const server = Bun.serve({
156159
});
157160
}
158161

162+
if (url.pathname === '/debug/artifacts') {
163+
const entries = fs.readdirSync(artifactsRoot, { recursive: true });
164+
const listing = entries.map(e => {
165+
const fullPath = path.join(artifactsRoot, String(e));
166+
try {
167+
const stat = fs.statSync(fullPath);
168+
return `${e} (${stat.size} bytes, ${stat.isDirectory() ? 'dir' : 'file'})`;
169+
} catch {
170+
return `${e} (stat failed)`;
171+
}
172+
});
173+
return new Response(JSON.stringify({ artifactsRoot, entries: listing }, null, 2), {
174+
headers: { 'Content-Type': 'application/json' },
175+
});
176+
}
177+
159178
return new Response('not found', { status: 404 });
160179
},
161180
});

‎Example/e2etest/scripts/prepare-local-update-artifacts.ts‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,10 @@ async function main() {
154154
['hdiff', v1, v2, '--output', ppkDiff, '--no-interactive'],
155155
projectRoot,
156156
);
157-
console.log('Ppk diff generated.');
157+
if (!fs.existsSync(ppkDiff)) {
158+
throw new Error(`ppk diff file not found after generation: ${ppkDiff}`);
159+
}
160+
console.log(`Verified ppk diff: ${ppkDiff} (${fs.statSync(ppkDiff).size} bytes)`);
158161

159162
if (platform === 'android') {
160163
const apkPath = path.join(
@@ -181,7 +184,11 @@ async function main() {
181184
],
182185
projectRoot,
183186
);
184-
console.log('Package diff generated.');
187+
const packageDiffPath = path.join(artifactsDir, LOCAL_UPDATE_FILES.packageDiff);
188+
if (!fs.existsSync(packageDiffPath)) {
189+
throw new Error(`Package diff file not found after generation: ${packageDiffPath}`);
190+
}
191+
console.log(`Verified package diff: ${packageDiffPath} (${fs.statSync(packageDiffPath).size} bytes)`);
185192
}
186193

187194
const manifestPath = path.join(artifactsDir, 'manifest.json');

0 commit comments

Comments
 (0)