Skip to content
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

Merged
merged 33 commits into from
May 21, 2023

Conversation

cirospaciari
Copy link
Collaborator

@cirospaciari cirospaciari commented May 17, 2023

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

@github-actions
Copy link
Contributor

github-actions bot commented May 17, 2023

@cirospaciari 25 files with test failures on linux-x64:

  • test/bundler/api.test.ts
  • test/bundler/bundler_browser.test.ts
  • test/bundler/bundler_edgecase.test.ts
  • test/bundler/bundler_jsx.test.ts
  • test/bundler/bundler_naming.test.ts
  • test/bundler/bundler_plugin.test.ts
  • test/bundler/esbuild/dce.test.ts
  • test/bundler/esbuild/default.test.ts
  • test/bundler/esbuild/extra.test.ts
  • test/bundler/esbuild/importstar.test.ts
  • test/bundler/esbuild/loader.test.ts
  • test/bundler/esbuild/packagejson.test.ts
  • test/bundler/esbuild/splitting.test.ts
  • test/bundler/esbuild/ts.test.ts
  • test/bundler/esbuild/tsconfig.test.ts
  • test/cli/hot/hot.test.ts
  • test/cli/run/preload-test.test.js
  • test/cli/run/run-cjs.test.ts
  • test/js/bun/plugin/plugins.test.ts
  • test/js/bun/resolve/png/test-png-import.test.js
  • test/js/bun/test/preload-test.test.js
  • test/js/bun/test/snapshot-tests/snapshots/more-snapshots/different-directory.test.ts
  • test/js/bun/test/snapshot-tests/snapshots/more.test.ts
  • test/js/node/child_process/child_process-node.test.js
  • test/transpiler/transpiler.test.js

View test output

#595288473add07fb95ed7d7c09fe76ea47d6247c

@github-actions
Copy link
Contributor

github-actions bot commented May 17, 2023

@cirospaciari 25 files with test failures on linux-x64-baseline:

  • test/bundler/api.test.ts
  • test/bundler/bundler_browser.test.ts
  • test/bundler/bundler_edgecase.test.ts
  • test/bundler/bundler_jsx.test.ts
  • test/bundler/bundler_naming.test.ts
  • test/bundler/bundler_plugin.test.ts
  • test/bundler/esbuild/dce.test.ts
  • test/bundler/esbuild/default.test.ts
  • test/bundler/esbuild/extra.test.ts
  • test/bundler/esbuild/importstar.test.ts
  • test/bundler/esbuild/loader.test.ts
  • test/bundler/esbuild/packagejson.test.ts
  • test/bundler/esbuild/splitting.test.ts
  • test/bundler/esbuild/ts.test.ts
  • test/bundler/esbuild/tsconfig.test.ts
  • test/cli/hot/hot.test.ts
  • test/cli/run/preload-test.test.js
  • test/cli/run/run-cjs.test.ts
  • test/js/bun/plugin/plugins.test.ts
  • test/js/bun/resolve/png/test-png-import.test.js
  • test/js/bun/test/preload-test.test.js
  • test/js/bun/test/snapshot-tests/snapshots/more-snapshots/different-directory.test.ts
  • test/js/bun/test/snapshot-tests/snapshots/more.test.ts
  • test/js/node/child_process/child_process-node.test.js
  • test/transpiler/transpiler.test.js

View test output

#687ea435cde2b086dfb3ed99c0c4fa399fd7ab29

@github-actions
Copy link
Contributor

github-actions bot commented May 17, 2023

@cirospaciari 26 files with test failures on bun-darwin-x64-baseline:

  • test/bundler/api.test.ts
  • test/bundler/bundler_browser.test.ts
  • test/bundler/bundler_edgecase.test.ts
  • test/bundler/bundler_jsx.test.ts
  • test/bundler/bundler_naming.test.ts
  • test/bundler/bundler_plugin.test.ts
  • test/bundler/esbuild/dce.test.ts
  • test/bundler/esbuild/default.test.ts
  • test/bundler/esbuild/extra.test.ts
  • test/bundler/esbuild/importstar.test.ts
  • test/bundler/esbuild/loader.test.ts
  • test/bundler/esbuild/packagejson.test.ts
  • test/bundler/esbuild/splitting.test.ts
  • test/bundler/esbuild/ts.test.ts
  • test/bundler/esbuild/tsconfig.test.ts
  • test/cli/run/preload-test.test.js
  • test/cli/run/run-cjs.test.ts
  • test/js/bun/plugin/plugins.test.ts
  • test/js/bun/resolve/png/test-png-import.test.js
  • test/js/bun/sqlite/sqlite.test.js
  • test/js/bun/test/preload-test.test.js
  • test/js/bun/test/snapshot-tests/snapshots/more-snapshots/different-directory.test.ts
  • test/js/bun/test/snapshot-tests/snapshots/more.test.ts
  • test/js/third_party/socket.io/socket.io.test.ts
  • test/js/web/timers/setTimeout.test.js
  • test/transpiler/transpiler.test.js

View test output

#687ea435cde2b086dfb3ed99c0c4fa399fd7ab29

@cirospaciari cirospaciari force-pushed the ciro/patch-tls branch 3 times, most recently from 49b350a to 3e36c2b Compare May 18, 2023 22:28
@cirospaciari cirospaciari marked this pull request as ready for review May 18, 2023 22:28
@Jarred-Sumner
Copy link
Collaborator

lets merge once macOS tests run

@Jarred-Sumner
Copy link
Collaborator

macOS x64 test is timing out

@github-actions
Copy link
Contributor

github-actions bot commented May 19, 2023

prettier errors have been resolved. Thank you.

#687ea435cde2b086dfb3ed99c0c4fa399fd7ab29

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;
Copy link
Collaborator

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.

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;
}

Copy link
Collaborator Author

@cirospaciari cirospaciari May 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done on 5d28303 fixed throw on 52daa77

} else {
break :brk .{
.result = .{
.null_terminated = buf.toOwnedSliceSentinel(0) catch unreachable,
Copy link
Collaborator

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

@Jarred-Sumner Jarred-Sumner merged commit 3870f67 into main May 21, 2023
15 of 22 checks passed
@Jarred-Sumner Jarred-Sumner deleted the ciro/patch-tls branch May 21, 2023 16:50
@Jarred-Sumner
Copy link
Collaborator

Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants