Skip to content

Commit 89fea9b

Browse files
committed
initialize ICU
This makes functions like new Intl.DateTimeFormat() not crash.
1 parent ba0505c commit 89fea9b

File tree

7 files changed

+22
-8
lines changed

7 files changed

+22
-8
lines changed

.github/actions/install/action.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ inputs:
1717
zig-v8:
1818
description: 'zig v8 version to install'
1919
required: false
20-
default: 'v0.1.18'
20+
default: 'v0.1.19'
2121
v8:
2222
description: 'v8 version to install'
2323
required: false

Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ ARG ZIG=0.14.0
55
ARG ZIG_MINISIG=RWSGOq2NVecA2UPNdBUZykf1CCb147pkmdtYxgb3Ti+JO/wCYvhbAb/U
66
ARG ARCH=x86_64
77
ARG V8=11.1.134
8-
ARG ZIG_V8=v0.1.18
8+
ARG ZIG_V8=v0.1.19
99

1010
RUN apt-get update -yq && \
1111
apt-get install -yq xz-utils \

build.zig.zon

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
.hash = "tigerbeetle_io-0.0.0-ViLgxpyRBAB5BMfIcj3KMXfbJzwARs9uSl8aRy2OXULd",
1414
},
1515
.v8 = .{
16-
.url = "https://github.com/lightpanda-io/zig-v8-fork/archive/97bcfb61da8c97de1321d677a6727a927a9db9a4.tar.gz",
17-
.hash = "v8-0.0.0-xddH69DoIADZ8YXZ_EIx_tKdQKEoGsgob_3_ZIi0O_nV",
16+
.url = "https://github.com/lightpanda-io/zig-v8-fork/archive/5d46f159ca44535cfb4fccd9d46f719eb7eac5fc.tar.gz",
17+
.hash = "v8-0.0.0-xddH66zuIADu8FcQx2kkczC0yhqBY7LoA08-GRWF_zMA",
1818
},
1919
//.v8 = .{ .path = "../zig-v8-fork" },
2020
//.tigerbeetle_io = .{ .path = "../tigerbeetle-io" },

src/browser/browser.zig

+11
Original file line numberDiff line numberDiff line change
@@ -940,3 +940,14 @@ fn timestamp() u32 {
940940
const ts = std.posix.clock_gettime(std.posix.CLOCK.MONOTONIC) catch unreachable;
941941
return @intCast(ts.sec);
942942
}
943+
944+
const testing = @import("../testing.zig");
945+
test "Browser" {
946+
var runner = try testing.jsRunner(testing.tracking_allocator, .{});
947+
defer runner.deinit();
948+
949+
// this will crash if ICU isn't properly configured / ininitialized
950+
try runner.testCases(&.{
951+
.{ "new Intl.DateTimeFormat()", "[object Intl.DateTimeFormat]" },
952+
}, .{});
953+
}

src/main.zig

+2-2
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ pub fn main() !void {
6565
else => {},
6666
}
6767

68-
const platform = Platform.init();
68+
const platform = try Platform.init();
6969
defer platform.deinit();
7070

7171
var app = try App.init(alloc, .{
@@ -423,7 +423,7 @@ var test_wg: std.Thread.WaitGroup = .{};
423423
test "tests:beforeAll" {
424424
try parser.init();
425425
test_wg.startMany(3);
426-
_ = Platform.init();
426+
_ = try Platform.init();
427427

428428
{
429429
const address = try std.net.Address.parseIp("127.0.0.1", 9582);

src/main_wpt.zig

+1-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ pub fn main() !void {
118118
}
119119

120120
// initialize VM JS lib.
121-
const platform = Platform.init();
121+
const platform = try Platform.init();
122122
defer platform.deinit();
123123

124124
// prepare libraries to load on each test case.

src/runtime/js.zig

+4-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@ const SCOPE_ARENA_RETAIN = 1024 * 64;
3434
pub const Platform = struct {
3535
inner: v8.Platform,
3636

37-
pub fn init() Platform {
37+
pub fn init() !Platform {
38+
if (v8.initV8ICU() == false) {
39+
return error.FailedToInitializeICU;
40+
}
3841
const platform = v8.Platform.initDefault(0, true);
3942
v8.initV8Platform(platform);
4043
v8.initV8();

0 commit comments

Comments
 (0)