aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/cli.zig2
-rw-r--r--src/http_client_async.zig29
-rw-r--r--src/install/install.zig14
-rw-r--r--src/resolver/tsconfig_json.zig15
-rw-r--r--src/string_immutable.zig2
-rw-r--r--src/thread_pool.zig9
6 files changed, 60 insertions, 11 deletions
diff --git a/src/cli.zig b/src/cli.zig
index e9798eba8..32ad9bca5 100644
--- a/src/cli.zig
+++ b/src/cli.zig
@@ -696,7 +696,7 @@ pub const HelpCommand = struct {
\\> <r> <b><magenta>bun <r><d> ./a.ts ./b.jsx<r> Bundle dependencies of input files into a <r><magenta>.bun<r>
\\
\\> <r> <b><cyan>create <r><d>next ./app<r> Start a new project from a template <d>(bun c)<r>
- \\> <r> <b><magenta>run <r><d> test <r> Run a package.json script or executable<r>
+ \\> <r> <b><magenta>run <r><d> test <r> Run JavaScript with bun, a package.json script, or a bin<r>
\\> <r> <b><green>install<r> Install dependencies for a package.json <d>(bun i)<r>
\\> <r> <b><blue>add <r><d> {s:<16}<r> Add a dependency to package.json <d>(bun a)<r>
\\> <r> remove <r><d> {s:<16}<r> Remove a dependency from package.json <d>(bun rm)<r>
diff --git a/src/http_client_async.zig b/src/http_client_async.zig
index f3fbd45cf..33f004f28 100644
--- a/src/http_client_async.zig
+++ b/src/http_client_async.zig
@@ -42,7 +42,34 @@ pub fn onThreadStart(_: ?*anyopaque) ?*anyopaque {
default_allocator = default_arena.allocator();
NetworkThread.address_list_cached = NetworkThread.AddressListCache.init(default_allocator);
AsyncIO.global = AsyncIO.init(1024, 0) catch |err| {
- Output.prettyErrorln("<r><red>error<r>: Failed to initialize network thread: <red><b>{s}<r>.\nHTTP requests will not work. Please file an issue and run strace().", .{@errorName(err)});
+ log: {
+ if (comptime Environment.isLinux) {
+ if (err == error.SystemOutdated) {
+ Output.prettyErrorln(
+ \\<red>error<r>: Linux kernel version doesn't support io_uring, which Bun depends on.
+ \\
+ \\To fix this error: <b>please upgrade to a newer Linux kernel<r>.
+ \\
+ \\If you're using Windows Subsystem for Linux, here's how:
+ \\ 1. Open PowerShell as an administrator
+ \\ 2. Run this:
+ \\ <cyan>wsl --update<r>
+ \\ <cyan>wsl --shutdown<r>
+ \\
+ \\If that doesn't work (and you're on a Windows machine), try this:
+ \\ 1. Open Windows Update
+ \\ 2. Download any updates to Windows Subsystem for Linux
+ \\
+ \\If you're still having trouble, ask for help in bun's discord https://bun.sh/discord
+ \\
+ , .{});
+ break :log;
+ }
+ }
+
+ Output.prettyErrorln("<r><red>error<r>: Failed to initialize network thread: <red><b>{s}<r>.\nHTTP requests will not work. Please file an issue and run strace().", .{@errorName(err)});
+ }
+
Output.flush();
os.exit(1);
};
diff --git a/src/install/install.zig b/src/install/install.zig
index 5f890e832..051eebb03 100644
--- a/src/install/install.zig
+++ b/src/install/install.zig
@@ -185,7 +185,13 @@ const NetworkTask = struct {
PackageManager.instance.network_channel.writeItem(@fieldParentPtr(NetworkTask, "http", http)) catch {};
}
- const default_headers_buf: string = "Acceptapplication/vnd.npm.install-v1+json";
+ // We must use a less restrictive Acccept header value
+ // https://github.com/Jarred-Sumner/bun/issues/341
+ // https://www.jfrog.com/jira/browse/RTFACT-18398
+ const accept_header_value = "application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*";
+
+ const default_headers_buf: string = "Accept" ++ accept_header_value;
+
pub fn forManifest(
this: *NetworkTask,
name: string,
@@ -218,7 +224,7 @@ const NetworkTask = struct {
}
if (header_builder.header_count > 0) {
- header_builder.count("Accept", "application/vnd.npm.install-v1+json");
+ header_builder.count("Accept", accept_header_value);
if (last_modified.len > 0 and etag.len > 0) {
header_builder.content.count(last_modified);
}
@@ -236,7 +242,7 @@ const NetworkTask = struct {
header_builder.append("If-Modified-Since", last_modified);
}
- header_builder.append("Accept", "application/vnd.npm.install-v1+json");
+ header_builder.append("Accept", accept_header_value);
if (last_modified.len > 0 and etag.len > 0) {
last_modified = header_builder.content.append(last_modified);
@@ -1094,7 +1100,7 @@ const PackageInstall = struct {
return result;
} else |err| {
switch (err) {
- error.NotSameFilesystem, error.NotSupported => {
+ error.NotSameFileSystem, error.NotSupported => {
supported_method = .copyfile;
},
error.FileNotFound => return Result{
diff --git a/src/resolver/tsconfig_json.zig b/src/resolver/tsconfig_json.zig
index 68217191a..34732beb8 100644
--- a/src/resolver/tsconfig_json.zig
+++ b/src/resolver/tsconfig_json.zig
@@ -325,9 +325,24 @@ pub const TSConfigJSON = struct {
return &([_]string{});
}
const parts_count = std.mem.count(u8, text, ".");
+
+ if (parts_count == 0) {
+ if (!js_lexer.isIdentifier(text)) {
+ const warn = source.rangeOfString(loc);
+ log.addRangeWarningFmt(source, warn, allocator, "Invalid JSX member expression: \"{s}\"", .{text}) catch {};
+ return &([_]string{});
+ }
+
+ var members = allocator.alloc(string, 1) catch unreachable;
+
+ members[0] = text;
+ return members;
+ }
+
const parts = allocator.alloc(string, parts_count) catch unreachable;
var iter = std.mem.tokenize(u8, text, ".");
var i: usize = 0;
+
while (iter.next()) |part| {
if (!js_lexer.isIdentifier(part)) {
const warn = source.rangeOfString(loc);
diff --git a/src/string_immutable.zig b/src/string_immutable.zig
index 5ee958b40..8f347b047 100644
--- a/src/string_immutable.zig
+++ b/src/string_immutable.zig
@@ -482,7 +482,7 @@ pub fn eqlAnyComptime(self: string, comptime list: []const string) bool {
return false;
}
-/// Count the occurences of a character in an ASCII byte array
+/// Count the occurrences of a character in an ASCII byte array
/// uses SIMD
pub fn countChar(self: string, char: u8) usize {
var total: usize = 0;
diff --git a/src/thread_pool.zig b/src/thread_pool.zig
index 514225d98..03fe6f211 100644
--- a/src/thread_pool.zig
+++ b/src/thread_pool.zig
@@ -184,12 +184,13 @@ noinline fn notifySlow(self: *ThreadPool, is_waking: bool) void {
// We signaled to spawn a new thread
if (can_wake and sync.spawned < self.max_threads) {
- const spawn_config = std.Thread.SpawnConfig{};
- if (Environment.isMac) {
+ const spawn_config = if (Environment.isMac)
// stack size must be a multiple of page_size
// macOS will fail to spawn a thread if the stack size is not a multiple of page_size
- spawn_config.stack_size = ((self.stack_size + (std.mem.page_size / 2)) / std.mem.page_size) * std.mem.page_size;
- }
+ std.Thread.SpawnConfig{ .stack_size = ((std.Thread.SpawnConfig{}).stack_size + (std.mem.page_size / 2) / std.mem.page_size) * std.mem.page_size }
+ else
+ std.Thread.SpawnConfig{};
+
const thread = std.Thread.spawn(spawn_config, Thread.run, .{self}) catch return self.unregister(null);
// if (self.name.len > 0) thread.setName(self.name) catch {};
return thread.detach();