aboutsummaryrefslogtreecommitdiff
path: root/src/bun.js/node
diff options
context:
space:
mode:
Diffstat (limited to 'src/bun.js/node')
-rw-r--r--src/bun.js/node/node_fs.zig9
-rw-r--r--src/bun.js/node/types.zig12
2 files changed, 18 insertions, 3 deletions
diff --git a/src/bun.js/node/node_fs.zig b/src/bun.js/node/node_fs.zig
index 2068cca3f..826fde635 100644
--- a/src/bun.js/node/node_fs.zig
+++ b/src/bun.js/node/node_fs.zig
@@ -74,6 +74,7 @@ pub const AsyncReaddirTask = struct {
.arena = arena,
};
task.ref.ref(vm);
+ task.args.path.toThreadSafe();
JSC.WorkPool.schedule(&task.task);
@@ -157,6 +158,7 @@ pub const AsyncStatTask = struct {
.arena = arena,
};
task.ref.ref(vm);
+ task.args.path.toThreadSafe();
JSC.WorkPool.schedule(&task.task);
@@ -240,6 +242,7 @@ pub const AsyncReadFileTask = struct {
.arena = arena,
};
task.ref.ref(vm);
+ task.args.path.toThreadSafe();
JSC.WorkPool.schedule(&task.task);
@@ -904,7 +907,7 @@ pub const Arguments = struct {
}
pub fn fromJS(ctx: JSC.C.JSContextRef, arguments: *ArgumentsSlice, exception: JSC.C.ExceptionRef) ?Stat {
- const path = PathLike.fromJS(ctx, arguments, exception) orelse {
+ const path = PathLike.fromJSWithAllocator(ctx, arguments, bun.default_allocator, exception) orelse {
if (exception.* == null) {
JSC.throwInvalidArguments(
"path must be a string or TypedArray",
@@ -1405,7 +1408,7 @@ pub const Arguments = struct {
}
pub fn fromJS(ctx: JSC.C.JSContextRef, arguments: *ArgumentsSlice, exception: JSC.C.ExceptionRef) ?Readdir {
- const path = PathLike.fromJS(ctx, arguments, exception) orelse {
+ const path = PathLike.fromJSWithAllocator(ctx, arguments, bun.default_allocator, exception) orelse {
if (exception.* == null) {
JSC.throwInvalidArguments(
"path must be a string or TypedArray",
@@ -1972,7 +1975,7 @@ pub const Arguments = struct {
}
pub fn fromJS(ctx: JSC.C.JSContextRef, arguments: *ArgumentsSlice, exception: JSC.C.ExceptionRef) ?ReadFile {
- const path = PathOrFileDescriptor.fromJS(ctx, arguments, arguments.arena.allocator(), exception) orelse {
+ const path = PathOrFileDescriptor.fromJS(ctx, arguments, bun.default_allocator, exception) orelse {
if (exception.* == null) {
JSC.throwInvalidArguments(
"path must be a string or a file descriptor",
diff --git a/src/bun.js/node/types.zig b/src/bun.js/node/types.zig
index 81073463a..3ba3db5b9 100644
--- a/src/bun.js/node/types.zig
+++ b/src/bun.js/node/types.zig
@@ -629,6 +629,12 @@ pub const PathLike = union(Tag) {
}
}
+ pub fn toThreadSafe(this: *PathLike) void {
+ if (this.* == .slice_with_underlying_string) {
+ this.slice_with_underlying_string.toThreadSafe();
+ }
+ }
+
pub fn deinitAndUnprotect(this: *const PathLike) void {
switch (this.*) {
.slice_with_underlying_string => |val| {
@@ -1050,6 +1056,12 @@ pub const PathOrFileDescriptor = union(Tag) {
}
}
+ pub fn toThreadSafe(this: *PathOrFileDescriptor) void {
+ if (this.* == .path) {
+ this.path.toThreadSafe();
+ }
+ }
+
pub fn deinitAndUnprotect(this: PathOrFileDescriptor) void {
if (this == .path) {
this.path.deinitAndUnprotect();