aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2022-09-28 23:38:54 -0700
committerGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2022-09-28 23:38:54 -0700
commite69e8d35b9044074c3ef3ff59ebdaa520068df64 (patch)
treec24ed091b73b0ccdaedd0b4d117716a5ba191027
parent9438540bf9dac4c9a5c2ac858233abcc8e1fa446 (diff)
downloadbun-e69e8d35b9044074c3ef3ff59ebdaa520068df64.tar.gz
bun-e69e8d35b9044074c3ef3ff59ebdaa520068df64.tar.zst
bun-e69e8d35b9044074c3ef3ff59ebdaa520068df64.zip
Fix `unreachable`
-rw-r--r--src/bun.js/webcore/streams.zig9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/bun.js/webcore/streams.zig b/src/bun.js/webcore/streams.zig
index 2695a43e2..65a34f0ce 100644
--- a/src/bun.js/webcore/streams.zig
+++ b/src/bun.js/webcore/streams.zig
@@ -7,7 +7,7 @@ const ZigURL = @import("../../url.zig").URL;
const HTTPClient = @import("http");
const NetworkThread = HTTPClient.NetworkThread;
const AsyncIO = NetworkThread.AsyncIO;
-const JSC = @import("root").JSC;
+const JSC = @import("javascript_core");
const js = JSC.C;
const Method = @import("../../http/method.zig").Method;
@@ -1118,9 +1118,12 @@ pub const FileSink = struct {
}
fn cleanup(this: *FileSink) void {
- this.unwatch(this.fd);
-
if (this.fd != std.math.maxInt(JSC.Node.FileDescriptor)) {
+ if (this.scheduled_count > 0) {
+ this.scheduled_count = 0;
+ this.unwatch(this.fd);
+ }
+
_ = JSC.Node.Syscall.close(this.fd);
this.fd = std.math.maxInt(JSC.Node.FileDescriptor);
}