Skip to content
Closed
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/codegen/generate-js2native.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ const sourceFiles = readdirRecursiveWithExclusionsAndExtensionsSync(
// requires adding its entry below.
const rustIdentifierPaths: Record<string, string> = {
"bun.rs": "bun.rs",
"ConsoleObject.rs": "jsc/ConsoleObject.rs",
"Counters.rs": "jsc/Counters.rs",
"FrameworkRouter.rs": "runtime/bake/FrameworkRouter.rs",
"Listener.rs": "runtime/socket/Listener.rs",
Expand Down
13 changes: 10 additions & 3 deletions src/js/node/worker_threads.ts
Original file line number Diff line number Diff line change
Expand Up @@ -469,10 +469,17 @@ function setupWorkerStdio(stdio) {
enumerable: true,
});
// node routes console.log through process.stdout/stderr; Bun's global console
// writes the fd directly, so rebind it to the captured streams when present.
// writes the fd directly. Rebind its output sink to the port-backed streams
// so console.log/warn/error/trace/count/time* are captured by
// worker.stdout/stderr, while keeping Bun's formatter and the global console
// object itself (so console.write, Symbol.asyncIterator, console.Console
// remain reachable). Those Bun-specific APIs address the process fds by
// design and are not routed through the port.
if (stdout || stderr) {
const { Console } = require("node:console");
globalThis.console = new Console(process.stdout, process.stderr);
$newRustFunction("ConsoleObject.rs", "setOutputStreams", 2)(
stdout ? process.stdout : undefined,
stderr ? process.stderr : undefined,
);
}
}

Expand Down
Loading
Loading