Skip to content

Commit a5a9573

Browse files
committed
fix: avoid throw inside finally block in FUSE test
- Restructure error handling to throw outside finally - Keep 10000ms timeouts (matches run-file-on-fuse.test.ts pattern) - Add comment explaining why timeouts are needed for FUSE cleanup
1 parent 04de59f commit a5a9573

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

test/cli/run/glob-on-fuse.test.ts

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@ describe.skipIf(!isLinux)("glob on a FUSE mount", () => {
1616
const mountpoint = tmpdirSync();
1717

1818
let pythonProcess: ReadableSubprocess | undefined = undefined;
19+
let result: T;
1920
let originalError: Error | undefined;
21+
let cleanupError: Error | undefined;
22+
2023
try {
2124
// setup FUSE filesystem (uses fuse-fs.py which returns DT_UNKNOWN)
2225
pythonProcess = spawn({
@@ -37,10 +40,9 @@ describe.skipIf(!isLinux)("glob on a FUSE mount", () => {
3740
}
3841
expect(fs.existsSync(join(mountpoint, "main.js"))).toBeTrue();
3942

40-
return await fn(mountpoint);
43+
result = await fn(mountpoint);
4144
} catch (e) {
4245
originalError = e instanceof Error ? e : new Error(String(e));
43-
throw e;
4446
} finally {
4547
if (pythonProcess) {
4648
try {
@@ -53,15 +55,27 @@ describe.skipIf(!isLinux)("glob on a FUSE mount", () => {
5355
} catch (e) {
5456
pythonProcess.kill("SIGKILL");
5557
console.error("python process errored:", await new Response(pythonProcess.stderr).text());
56-
// Don't re-throw cleanup errors to preserve original test failures
58+
// Capture cleanup error but don't throw inside finally
5759
if (!originalError) {
58-
throw e;
60+
cleanupError = e instanceof Error ? e : new Error(String(e));
5961
}
6062
}
6163
}
6264
}
65+
66+
// Re-throw errors outside finally block
67+
if (originalError) {
68+
throw originalError;
69+
}
70+
if (cleanupError) {
71+
throw cleanupError;
72+
}
73+
74+
return result!;
6375
}
6476

77+
// Set a long timeout so the test can clean up the filesystem mount itself
78+
// rather than getting interrupted by timeout (matches run-file-on-fuse.test.ts)
6579
test(
6680
"Bun.Glob.scanSync finds files on FUSE mount",
6781
async () => {
@@ -122,3 +136,5 @@ describe.skipIf(!isLinux)("glob on a FUSE mount", () => {
122136
);
123137
});
124138

139+
140+

0 commit comments

Comments
 (0)