diff options
author | 2023-06-01 19:19:06 -0300 | |
---|---|---|
committer | 2023-06-01 15:19:06 -0700 | |
commit | f9809f0044e59de10c9d64a89715c6008608358c (patch) | |
tree | 1fe2ffd9082ef46dac001a2d7e56db288710a5ee | |
parent | 4378ef8e97839f950ddfa180e466d0a8db187681 (diff) | |
download | bun-f9809f0044e59de10c9d64a89715c6008608358c.tar.gz bun-f9809f0044e59de10c9d64a89715c6008608358c.tar.zst bun-f9809f0044e59de10c9d64a89715c6008608358c.zip |
[napi] fix thread safe function callback (#3162)
* fixup
* add debug log message to event loop unexpected tag
* fix fmt
-rw-r--r-- | src/bun.js/event_loop.zig | 10 | ||||
-rw-r--r-- | src/bun.js/events.exports.js | 4 |
2 files changed, 10 insertions, 4 deletions
diff --git a/src/bun.js/event_loop.zig b/src/bun.js/event_loop.zig index ea7551b7f..c2125e64f 100644 --- a/src/bun.js/event_loop.zig +++ b/src/bun.js/event_loop.zig @@ -407,6 +407,7 @@ pub const EventLoop = struct { forever_timer: ?*uws.Timer = null, pub const Queue = std.fifo.LinearFifo(Task, .Dynamic); + const log = bun.Output.scoped(.EventLoop, false); pub fn tickWithCount(this: *EventLoop) u32 { var global = this.global; @@ -442,6 +443,10 @@ pub const EventLoop = struct { var transform_task: *JSC.napi.napi_async_work = task.get(JSC.napi.napi_async_work).?; transform_task.*.runFromJS(); }, + .ThreadSafeFunction => { + var transform_task: *ThreadSafeFunction = task.as(ThreadSafeFunction); + transform_task.call(); + }, @field(Task.Tag, @typeName(ReadFileTask)) => { var transform_task: *ReadFileTask = task.get(ReadFileTask).?; transform_task.*.runFromJS(); @@ -477,7 +482,10 @@ pub const EventLoop = struct { }, else => if (Environment.allow_assert) { bun.Output.prettyln("\nUnexpected tag: {s}\n", .{@tagName(task.tag())}); - } else unreachable, + } else { + log("\nUnexpected tag: {s}\n", .{@tagName(task.tag())}); + unreachable; + }, } global_vm.releaseWeakRefs(); diff --git a/src/bun.js/events.exports.js b/src/bun.js/events.exports.js index 482ef5f5d..61cff17d6 100644 --- a/src/bun.js/events.exports.js +++ b/src/bun.js/events.exports.js @@ -22,9 +22,7 @@ function EventEmitter(opts) { } this._maxListeners ??= undefined; - if ( - (this[kCapture] = opts?.captureRejections ? Boolean(opts?.captureRejections) : EventEmitterPrototype[kCapture]) - ) { + if ((this[kCapture] = opts?.captureRejections ? Boolean(opts?.captureRejections) : EventEmitterPrototype[kCapture])) { this.emit = emitWithRejectionCapture; } } |