-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(tls.connect) fix SNI on tls sockets and also servername (mongodb) #2934
Conversation
❌ @cirospaciari 25 files with test failures on linux-x64:
|
❌ @cirospaciari 25 files with test failures on linux-x64-baseline:
|
❌ @cirospaciari 26 files with test failures on bun-darwin-x64-baseline:
|
49b350a
to
3e36c2b
Compare
lets merge once macOS tests run |
macOS x64 test is timing out |
0dcb4c1
to
f4d944b
Compare
✅ |
a20492a
to
b31b286
Compare
3138bf2
to
afcc5d5
Compare
8f72995
to
8e91569
Compare
src/bun.js/api/server.zig
Outdated
fn init(comptime fieldname: []const u8, js_obj: JSC.JSValue, global: *JSC.JSGlobalObject, exception: JSC.C.ExceptionRef) ?BlobFileContentResult { | ||
if (JSC.WebCore.Body.Value.fromJS(global, js_obj)) |body| { | ||
if (body == .Blob and body.Blob.store != null and body.Blob.store.?.data == .file) { | ||
const pathlike = body.Blob.store.?.data.file.pathlike; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This entire function should be removed and replaced with a version of readFile
easier to call from Zig, like writeFileWithPathBuffer
.
bun/src/bun.js/node/node_fs.zig
Lines 3290 to 3428 in 1973975
pub fn readFile(this: *NodeFS, args: Arguments.ReadFile, comptime flavor: Flavor) Maybe(Return.ReadFile) { | |
var path: [:0]const u8 = undefined; | |
switch (comptime flavor) { | |
.sync => { | |
const fd = switch (args.path) { | |
.path => brk: { | |
path = args.path.path.sliceZ(&this.sync_error_buf); | |
break :brk switch (Syscall.open( | |
path, | |
os.O.RDONLY | os.O.NOCTTY, | |
0, | |
)) { | |
.err => |err| return .{ | |
.err = err.withPath(if (args.path == .path) args.path.path.slice() else ""), | |
}, | |
.result => |fd_| fd_, | |
}; | |
}, | |
.fd => |_fd| _fd, | |
}; | |
defer { | |
if (args.path == .path) | |
_ = Syscall.close(fd); | |
} | |
const stat_ = switch (Syscall.fstat(fd)) { | |
.err => |err| return .{ | |
.err = err, | |
}, | |
.result => |stat_| stat_, | |
}; | |
// Only used in DOMFormData | |
if (args.offset > 0) { | |
std.os.lseek_SET(fd, args.offset) catch {}; | |
} | |
// For certain files, the size might be 0 but the file might still have contents. | |
const size = @intCast( | |
u64, | |
@max( | |
@min( | |
stat_.size, | |
@intCast( | |
@TypeOf(stat_.size), | |
// Only used in DOMFormData | |
args.max_size orelse std.math.maxInt( | |
JSC.WebCore.Blob.SizeType, | |
), | |
), | |
), | |
0, | |
), | |
); | |
var buf = std.ArrayList(u8).init(bun.default_allocator); | |
buf.ensureTotalCapacityPrecise(size + 16) catch unreachable; | |
buf.expandToCapacity(); | |
var total: usize = 0; | |
while (total < size) { | |
switch (Syscall.read(fd, buf.items.ptr[total..buf.capacity])) { | |
.err => |err| return .{ | |
.err = err, | |
}, | |
.result => |amt| { | |
total += amt; | |
// There are cases where stat()'s size is wrong or out of date | |
if (total > size and amt != 0) { | |
buf.ensureUnusedCapacity(8096) catch unreachable; | |
buf.expandToCapacity(); | |
continue; | |
} | |
if (amt == 0) { | |
break; | |
} | |
}, | |
} | |
} else { | |
// https://github.com/oven-sh/bun/issues/1220 | |
while (true) { | |
switch (Syscall.read(fd, buf.items.ptr[total..buf.capacity])) { | |
.err => |err| return .{ | |
.err = err, | |
}, | |
.result => |amt| { | |
total += amt; | |
// There are cases where stat()'s size is wrong or out of date | |
if (total > size and amt != 0) { | |
buf.ensureUnusedCapacity(8096) catch unreachable; | |
buf.expandToCapacity(); | |
continue; | |
} | |
if (amt == 0) { | |
break; | |
} | |
}, | |
} | |
} | |
} | |
buf.items.len = total; | |
if (total == 0) { | |
buf.deinit(); | |
return switch (args.encoding) { | |
.buffer => .{ | |
.result = .{ | |
.buffer = Buffer.empty, | |
}, | |
}, | |
else => .{ | |
.result = .{ | |
.string = "", | |
}, | |
}, | |
}; | |
} | |
return switch (args.encoding) { | |
.buffer => .{ | |
.result = .{ | |
.buffer = Buffer.fromBytes(buf.items, bun.default_allocator, .Uint8Array), | |
}, | |
}, | |
else => .{ | |
.result = .{ | |
.string = buf.items, | |
}, | |
}, | |
}; | |
}, | |
else => {}, | |
} | |
return Maybe(Return.ReadFile).todo; | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} else { | ||
break :brk .{ | ||
.result = .{ | ||
.null_terminated = buf.toOwnedSliceSentinel(0) catch unreachable, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It’s fine for now but keep in mind that .toOwnedSlice potentially reallocates the array
Thank you |
Depends on Jarred-Sumner/uSockets#4 and Jarred-Sumner/uWebSockets#11
Fix: #2922
Fix: #2355
Fix: #1991
Fix: #2737
Fix: #2485
Fix: #313 (fastify will at least start after this)
Fix: #2955