diff --git a/src/crash_handler.zig b/src/crash_handler.zig index 846288fc3b..6a1ae522b2 100644 --- a/src/crash_handler.zig +++ b/src/crash_handler.zig @@ -1655,7 +1655,7 @@ pub fn dumpStackTrace(trace: std.builtin.StackTrace) void { pub fn dumpCurrentStackTrace(first_address: ?usize) void { var addrs: [32]usize = undefined; var stack: std.builtin.StackTrace = .{ .index = 0, .instruction_addresses = &addrs }; - std.debug.captureStackTrace(first_address, &stack); + std.debug.captureStackTrace(first_address orelse @returnAddress(), &stack); dumpStackTrace(stack); } diff --git a/src/install/install.zig b/src/install/install.zig index 826e8a131d..01ee56f24c 100644 --- a/src/install/install.zig +++ b/src/install/install.zig @@ -1562,7 +1562,7 @@ pub fn NewPackageInstall(comptime kind: PkgInstallKind) type { state.buf[i] = 0; const fullpath = state.buf[0..i :0]; - node_fs_for_package_installer.mkdirRecursiveOSPathImpl(void, {}, fullpath, 0, false); + _ = node_fs_for_package_installer.mkdirRecursiveOSPathImpl(void, {}, fullpath, 0, false); state.to_copy_buf = state.buf[fullpath.len..]; const cache_path_length = bun.windows.kernel32.GetFinalPathNameByHandleW(state.cached_package_dir.fd, &state.buf2, state.buf2.len, 0); diff --git a/src/string_immutable.zig b/src/string_immutable.zig index efaa676c17..82ac457212 100644 --- a/src/string_immutable.zig +++ b/src/string_immutable.zig @@ -1934,6 +1934,11 @@ pub fn toNTPath(wbuf: []u16, utf8: []const u8) [:0]u16 { // UNC absolute path, replace leading '\\' with '\??\UNC\' if (strings.hasPrefixComptime(utf8, "\\\\")) { + if (strings.hasPrefixComptime(utf8[2..], bun.windows.long_path_prefix_u8[2..])) { + const prefix = bun.windows.nt_object_prefix; + wbuf[0..prefix.len].* = prefix; + return wbuf[0 .. toWPathNormalized(wbuf[prefix.len..], utf8[4..]).len + prefix.len :0]; + } const prefix = bun.windows.nt_unc_object_prefix; wbuf[0..prefix.len].* = prefix; return wbuf[0 .. toWPathNormalized(wbuf[prefix.len..], utf8[2..]).len + prefix.len :0]; @@ -1956,6 +1961,11 @@ pub fn toNTPath16(wbuf: []u16, path: []const u16) [:0]u16 { } if (strings.hasPrefixComptimeUTF16(path, "\\\\")) { + if (strings.hasPrefixComptimeUTF16(path[2..], bun.windows.long_path_prefix_u8[2..])) { + const prefix = bun.windows.nt_object_prefix; + wbuf[0..prefix.len].* = prefix; + return wbuf[0 .. toWPathNormalized16(wbuf[prefix.len..], path[4..]).len + prefix.len :0]; + } const prefix = bun.windows.nt_unc_object_prefix; wbuf[0..prefix.len].* = prefix; return wbuf[0 .. toWPathNormalized16(wbuf[prefix.len..], path[2..]).len + prefix.len :0]; diff --git a/src/sys.zig b/src/sys.zig index 12b732a2a2..842087c8c7 100644 --- a/src/sys.zig +++ b/src/sys.zig @@ -3098,8 +3098,8 @@ pub fn directoryExistsAt(dir: anytype, subpath: anytype) JSC.Maybe(bool) { }; var basic_info: w.FILE_BASIC_INFORMATION = undefined; const rc = kernel32.NtQueryAttributesFile(&attr, &basic_info); - if (rc == .OBJECT_NAME_INVALID) { - bun.Output.warn("internal error: invalid object name: {}", .{bun.fmt.fmtOSPath(path, .{})}); + if (rc == .OBJECT_NAME_INVALID or rc == .BAD_NETWORK_PATH) { + bun.Output.warn("internal error: {s}: {}", .{ @tagName(rc), bun.fmt.fmtOSPath(path, .{}) }); } if (JSC.Maybe(bool).errnoSys(rc, .access)) |err| { syslog("NtQueryAttributesFile({}, {}, O_DIRECTORY | O_RDONLY, 0) = {} {d}", .{ dir_fd, bun.fmt.fmtOSPath(path, .{}), err, rc }); diff --git a/src/windows.zig b/src/windows.zig index bee2fd3c3b..8f6cbc5f5e 100644 --- a/src/windows.zig +++ b/src/windows.zig @@ -3075,6 +3075,7 @@ pub fn translateNTStatusToErrno(err: win32.NTSTATUS) bun.C.E { else => |t| { if (bun.Environment.isDebug) { bun.Output.warn("Called translateNTStatusToErrno with {s} which does not have a mapping to errno.", .{@tagName(t)}); + bun.crash_handler.dumpCurrentStackTrace(null); } return .UNKNOWN; }, diff --git a/test/integration/next-pages/test/dev-server-ssr-100.test.ts b/test/integration/next-pages/test/dev-server-ssr-100.test.ts index 269b88867d..b5813aee9d 100644 --- a/test/integration/next-pages/test/dev-server-ssr-100.test.ts +++ b/test/integration/next-pages/test/dev-server-ssr-100.test.ts @@ -116,40 +116,45 @@ afterAll(() => { } }); -test("ssr works for 100-ish requests", async () => { - expect(dev_server).not.toBeUndefined(); - expect(baseUrl).not.toBeUndefined(); - const lockfile = parseLockfile(root); - expect(lockfile).toMatchNodeModulesAt(root); - expect(lockfile).toMatchSnapshot(); +const timeout = Bun.version.includes("debug") ? 1_000_000 : 100_000; +test( + "ssr works for 100-ish requests", + async () => { + expect(dev_server).not.toBeUndefined(); + expect(baseUrl).not.toBeUndefined(); + const lockfile = parseLockfile(root); + expect(lockfile).toMatchNodeModulesAt(root); + expect(lockfile).toMatchSnapshot(); - const batchSize = 16; - const promises = []; - for (let j = 0; j < 100; j += batchSize) { - for (let i = j; i < j + batchSize; i++) { - promises.push( - (async () => { - const x = await fetch(`${baseUrl}/?i=${i}`, { - headers: { - "Cache-Control": "private, no-cache, no-store, must-revalidate", - }, - }); - expect(x.status).toBe(200); - const text = await x.text(); - console.count("Completed request"); - expect(text).toContain(`>${Bun.version}`); - })(), - ); + const batchSize = 16; + const promises = []; + for (let j = 0; j < 100; j += batchSize) { + for (let i = j; i < j + batchSize; i++) { + promises.push( + (async () => { + const x = await fetch(`${baseUrl}/?i=${i}`, { + headers: { + "Cache-Control": "private, no-cache, no-store, must-revalidate", + }, + }); + expect(x.status).toBe(200); + const text = await x.text(); + console.count("Completed request"); + expect(text).toContain(`>${Bun.version}`); + })(), + ); + } + await Promise.allSettled(promises); } - await Promise.allSettled(promises); - } - const x = await Promise.allSettled(promises); - const failing = x.filter(x => x.status === "rejected").map(x => x.reason!); - if (failing.length) { - throw new AggregateError(failing, failing.length + " requests failed", {}); - } - for (const y of x) { - expect(y.status).toBe("fulfilled"); - } -}, 100000); + const x = await Promise.allSettled(promises); + const failing = x.filter(x => x.status === "rejected").map(x => x.reason!); + if (failing.length) { + throw new AggregateError(failing, failing.length + " requests failed", {}); + } + for (const y of x) { + expect(y.status).toBe("fulfilled"); + } + }, + timeout, +);