Skip to content

fix(desktop): show console output of deno desktop --hmr apps on Windows - #37123

Open
Aschenbath wants to merge 1 commit into
denoland:mainfrom
Aschenbath:fix/desktop-hmr-windows-console
Open

Aschenbath wants to merge 1 commit into
denoland:mainfrom
Aschenbath:fix/desktop-hmr-windows-console

Conversation

@Aschenbath

Copy link
Copy Markdown

Closes #36501

On Windows, console.log and console.error from a deno desktop --hmr app never reached the terminal.

The laufey backend (laufey_webview.exe) is a GUI-subsystem executable. When deno desktop --hmr starts it from a console, Windows gives it no console and no standard handles: GetStdHandle(STD_OUTPUT_HANDLE) and GetStdHandle(STD_ERROR_HANDLE) both return null in the backend, so everything the runtime writes is dropped. When deno's output is redirected to a file or pipe, the handles are passed explicitly and the output shows up, which is why this only happens in a real console.

At startup, rt_desktop now checks whether DENO_DESKTOP_HMR is set and the process has no console. If so, it attaches to the parent's console (AttachConsole(ATTACH_PARENT_PROCESS)), and points stdout and stderr at CONOUT$ where they're still null. Handles the parent passed explicitly, such as a pipe or a file, are kept. DENO_DESKTOP_HMR is only set for development runs, so an app started normally, e.g. from Explorer, still runs without a console.

Testing

Windows 11, main.ts containing console.log("hello-from-desktop"); console.error("err-from-desktop");, deno desktop --hmr main.ts with the webview backend:

released 2.9.8 this branch (deno + denort.dll built locally)
real console neither line appears both lines appear
output redirected to a file both lines both lines

To read the real console, I started deno in a new console window (CREATE_NEW_CONSOLE), attached to that console and read its screen buffer. A temporary diagnostic in this function confirmed that both standard handles are null in the backend before this change.

cargo clippy -p denort_desktop -- -D warnings, cargo fmt --check and dprint are clean.

Not covered: stdin is left as it was, and I haven't checked the CEF backend.

AI disclosure

This PR was written primarily by Claude Code (Claude Opus 5.5), including the change, the investigation and this description.

🤖 Generated with Claude Code

…dows

Closes denoland#36501

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
NetOpWibby pushed a commit to theende/ende that referenced this pull request Nov 7, 2026
…dows

Closes denoland/deno#36501

Ende changes: the dev-mode check reads `ENDE_DESKTOP_HMR`, and the call
sits at the top of `runtime_main` (Ende's `laufey_runtime_start` body)
instead of a `laufey::main!` closure.

(cherry picked from commit 9e35c47cf3081ea89d80d0bd6bfc96b2698c2500)

Upstream: denoland/deno#37123
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

console.log doesn't work on Windows 11 when using deno desktop --hmr

2 participants