Writing 12 min read
Why Qwen Code spent 25 minutes publishing a page it wrote in milliseconds
Qwen Code's Artifact tool blocked on "Publishing artifact" until I gave up. The page had been on disk the whole time: the tool was waiting for a browser window to close. How I traced it from a timer to one awaited line, reproduced it without touching my real setup, and wrote a fix.
While I keep looking for my next job, one of the things I’ve enjoyed most is finding bugs in the tools I use every day and following them all the way down. Qwen Code, the open-source agent I run in front of my local Qwen model, has given me two good ones so far. The first ended with a fix merged upstream. This post is the second.
I also want it to show how I work a problem like this, not just the answer: what I looked at first, how I checked each idea before building on it, how I reproduced it without touching my real setup, and what goes into a bug I file. None of that is specific to Qwen Code. It’s the same methodology, and the same kind of documentation, that I use with every technology I work on, from Spark and Kafka to API gateways and AI agents. If you’re a hiring manager or an engineer deciding whether I’d fit your team, this post is an example of how I take a problem from first symptom to a fix the maintainers can act on.
The short version:
- Publishing an artifact is two jobs: write the page to disk, then open it in a browser. The first takes milliseconds.
- The second job waits for the program that opens the browser to exit, with no time limit. On my machine that program runs Chrome in the foreground, so it doesn’t exit until the Chrome window is closed.
- Whether it hangs depends on whether a Chrome window happens to be open already, which is why it looked random. It isn’t new: the same code has shipped in every version with the Artifact tool.
- There is a one-line workaround, and I wrote a small fix that I’ve tested against a reproduction.
Step 1: the symptom
Qwen Code has an Artifact tool: the agent writes an HTML page, such as a report or an interactive demo, and Qwen Code publishes it and opens it in the browser. I was building a 3D diorama of the Eiffel Tower under construction, and the agent finished and went to publish it. Then this:
The timer at 22 minutes 45 seconds, with my note from the time. The step before it, writing artifact.html, took a fraction of a second.
At about 25 minutes I stopped the session and resumed it. Qwen Code showed the Artifact call as failed, and the model reported:
x Artifact Publishing artifact from artifact.html
Status: the deliverable is finished and verified. Only the Artifact publish failed — that call returned
"not recorded — likely interrupted by network failure, abort, or process exit", so no link was produced.
I asked it to try again, and the second publish finished in under half a second. It had happened before in other projects, too. Something that hangs for half an hour and then works instantly is not a slow network or a big file. It’s something waiting for something else.
Step 2: what the logs say
Qwen Code writes each session to a JSON Lines file under ~/.qwen/projects/, including a telemetry entry with the
duration of every tool call. That’s the first place I look, because it records what happened instead of what the model
says happened. For this session:
| Time (local) | Version | What the log shows |
|---|---|---|
| 02:32:54 | 0.27.3 | The model calls artifact on artifact.html. There is no result for this call, ever. |
| 02:32 | ~/.qwen/artifacts/75e667b479faaeee/index.html is written: the page was published |
|
| ~02:56 | I stop the session. Qwen Code’s auto-update installs 0.27.4 after this. | |
| 03:07:59 | 0.27.4 | The same call again: 440 ms, success |
So the page was on disk within the first second. The tool just never said so. And the version changed between the two attempts, so before blaming anything I had to know whether this was new.
Step 3: is it new?
My note in the screenshot says it seemed to be happening more often lately. That’s worth checking, because “it started recently” sends you looking at recent changes, and if it’s wrong you look in the wrong place.
I wrote a short script that reads every session log on my machine, finds every Artifact call, and pairs it with the duration Qwen Code recorded. These are all the calls that got as far as opening a browser:
Normal (11)Slow (3)Never returned (4)
Every call as a table
| When (UTC) | Version | Project | Duration |
|---|---|---|---|
| 2026-09-18 00:51 | 0.24.0 | chopin | 348 s (6 min) |
| 2026-09-18 01:08 | 0.24.0 | chopin | never returned |
| 2026-09-18 01:12 | 0.24.0 | chopin | 0.48 s |
| 2026-09-29 07:37 | 0.24.6 | fill-in-the-prompt | 0.46 s |
| 2026-09-29 07:45 | 0.24.6 | fill-in-the-prompt | 0.36 s |
| 2026-09-29 07:53 | 0.24.6 | fill-in-the-prompt | 0.29 s |
| 2026-09-29 07:54 | 0.24.6 | fill-in-the-prompt | 0.32 s |
| 2026-09-29 08:08 | 0.24.6 | fill-in-the-prompt | 0.30 s |
| 2026-09-29 09:00 | 0.24.6 | fill-in-the-prompt | 0.36 s |
| 2026-10-26 23:43 | 0.26.1 | bug-review | 0.82 s |
| 2026-11-01 13:48 | 0.26.5 | project-summary | never returned |
| 2026-11-11 00:43 | 0.27.2 | slinky-original | 2,066 s (34 min) |
| 2026-11-15 00:54 | 0.27.3 | submarine | never returned |
| 2026-11-15 01:07 | 0.27.3 | submarine | 0.26 s |
| 2026-11-15 01:11 | 0.27.3 | submarine | 0.27 s |
| 2026-11-15 01:18 | 0.27.3 | submarine | 12.6 s |
| 2026-11-15 07:32 | 0.27.3 | Eiffel-tower | never returned |
| 2026-11-15 08:07 | 0.27.4 | Eiffel-tower | 0.44 s |
qwen-code.tool_call entries in my session logs. "Never
returned" means the call was still running when I stopped the session. Left out: 13 calls that
the tool rejected within milliseconds (wrong page format, missing file), so they never got as far as opening a
browser.
Two things stood out. Most calls finish in under a second, and the bad ones don’t get gradually worse: they either finish or wait for minutes, half an hour, or forever. And the bad ones span four minor versions, from 0.24.0 in September to 0.27.3. I compared the browser-launching code in each installed version (Qwen Code keeps every version it updates to): it is byte-for-byte the same from 0.24.5 through 0.27.4.
So it’s not a regression. It looked like one because I’ve been using the Artifact tool more: three of the hangs were in the last five days.
Step 4: who is still waiting?
If a call “never returned”, something was holding it. Qwen Code itself was gone, since I had stopped the session, so I looked at the process table for anything that still mentioned the artifact:
PID ELAPSED COMMAND
345049 06:38:38 /bin/sh /usr/bin/xdg-open file:///home/…/.qwen/artifacts/75e667b479faaeee/index.html
345134 06:38:38 /opt/google/chrome/chrome /home/…/.qwen/artifacts/75e667b479faaeee/index.html
That is the answer in two lines, more than six hours after the hang. xdg-open is the standard Linux command for “open
this with the default app”. Qwen Code started it to show me the page. It started Chrome, and it is still blocked,
waiting for that Chrome to exit. Its parent is now init, because the Qwen Code process that started it is gone. And
the Chrome window it opened is still open.
Now there were two questions: why does Qwen Code wait for xdg-open, and why does xdg-open wait for Chrome?
Step 5: read the code that ran
I read the source at the version that actually ran (0.27.4 is identical to 0.27.3 here, and so is main). After the
page is written, the Artifact tool opens it, in
artifact-tool.ts:
// Open in the browser unless disabled. Best-effort: never fail the publish
// because the browser could not be launched.
if (this.shouldAutoOpen) {
try {
await this.openUrl(url, { allowFile: true, allowedFilePaths: filePath ? [filePath] : [] });
} catch (err) {
debugLogger.warn(`Failed to open browser for artifact "${title}": ${getErrorMessage(err)}`);
}
}
The comment says best-effort, and for errors it is: a failure is caught and logged. But the call is awaited, so the
tool’s result waits for however long opening the browser takes. On Linux, that ends up in
secure-browser-launcher.ts:
const execFileAsync = promisify(execFile);
// …
const execOptions = {
env: { ...process.env, SHELL: undefined },
// Detach the browser process so it doesn't block
detached: true,
stdio: 'ignore',
};
try {
await execFileAsync(command, args, execOptions); // command is 'xdg-open'
The comment states the intent: “so it doesn’t block”. But in Node.js, detached only puts the child process in its
own process group. It doesn’t change when execFile reports back, which is when the child exits. There’s no
timeout either. So whatever xdg-open does, the tool waits for all of it.
Step 6: why only sometimes
The second half is xdg-open. On a Linux desktop like GNOME or KDE, it hands the job to the desktop, which returns at
once. Under WSL, the Linux layer on my Windows machine, there is no Linux desktop: XDG_CURRENT_DESKTOP is empty, and
Linux apps such as Chrome show up as Windows windows through WSLg. So xdg-open (version 1.1.3 here) uses its generic
mode: it looks up the program for text/html, which is Chrome, and runs it in the foreground, then exits when it
does.
What Chrome does next depends on what’s already running. Chrome allows one main browser process per profile. A new
chrome command that finds one already running passes the page to it and exits in a fraction of a second. If there
isn’t one, the new process becomes the browser, and lives until its window is closed. Switch between the cases:
Doing workBlocked, waiting on the process belowRunning, not blocking anyone
The page is on disk after a few milliseconds. Everything after that is waiting: the tool waits for xdg-open, and xdg-open waits for the Chrome it started. Nothing returns until a person closes that window, which may be behind the terminal or on another monitor.
Chrome allows one main browser process per profile. A new chrome command that finds one already running passes the page to it and exits. xdg-open exits right after, and the tool returns in under half a second. Same code, same wait; there is just nothing long to wait for.
The opener still gets a few seconds, so a real failure (no xdg-open, an error exit) still reaches the existing fallbacks. If it is still running after that, it has started a browser, which is success. Qwen Code lets go of it and returns, and the browser lives on its own.
Every symptom fits. The first publish of a session often hangs. Restarting and retrying succeeds in 440 ms, because the Chrome window from the first attempt is still open. And “already published” after a restart is true: the page was on disk all along. Chrome’s own history on my machine confirms that each of these auto-opens landed in WSLg Chrome.
The slow calls in the chart fit the same pattern. The mechanism says each one ended when its Chrome window was closed. I can’t prove that from the logs for the older ones, but nothing else in the call path takes that long.
Step 7: reproduce it, small first
An explanation is a theory until I can make it happen on demand. I wanted two reproductions: one as small as possible, and one through the real program.
Neither one may touch my real browser or settings. So both use a stand-in “browser”: a tiny shell script that logs that
it opened, sleeps for a set number of seconds, and exits, like a Chrome window that someone closes after N seconds. A
throwaway set of XDG settings in /tmp makes it the text/html handler, and everything else is real: the real
/usr/bin/xdg-open, and the real function from the installed Qwen Code.
The small one imports openBrowserSecurely() from the installed 0.27.4 bundle and times one call. As a control, it
also times the path Qwen Code takes when the BROWSER variable is set, which uses its own detached launcher:
A) xdg-open path (current behaviour): openBrowserSecurely() resolved after 10.2 s
B) BROWSER env path (launchDetached): openBrowserSecurely() resolved after 0.0 s
[fake-browser] 09:38:11 opened: /tmp/qwen-xdg-repro-nldeyM/artifact/index.html
[fake-browser] 09:38:21 window closed
REPRODUCED: the xdg-open path blocks for the browser's whole lifetime (10s); the detached path returns immediately.
The full one runs an interactive Qwen Code session in a detached tmux window and asks it to publish a page. (It
has to be interactive: the Artifact tool isn’t available in headless -p mode, which I found out by trying.) Polling
the screen every few seconds showed the same climbing timer as my screenshot:
[ 10s] Artifact Publishing artifact from page.html 7s
[ 32s] Artifact Publishing artifact from page.html 29s
[ 64s] Artifact Publishing artifact from page.html 1m 2s
[ 69s] ✓ Artifact Publishing artifact from page.html
TOOL artifact duration_ms= 64744
It turned to ✓ the moment the stand-in browser exited.
| Scenario | Stand-in browser open for | Call returned after |
|---|---|---|
Small: current code (xdg-open) |
10 s | 10.2 s (12.2 s in an earlier run) |
Small: BROWSER set (Qwen Code’s own detached launcher) |
10 s | 0.0 s |
| Full: Qwen Code 0.27.4, default settings | 60 s | 64.7 s |
Full: with QWEN_ARTIFACT_NO_AUTO_OPEN=1 |
60 s | 0.03 s |
| Small: my proposed fix | 10 s | 3.0 – 5.3 s |
Step 8: a small fix
The fix goes where the wait is. Instead of waiting for the opener to exit, Qwen Code can give it a short grace period:
- If it exits successfully in that time, that’s success, as today.
- If it fails (missing program, error exit), that’s a failure, so the existing fallbacks (
gnome-open,kde-open,firefoxand others) still run, as today. - If it’s still running after three seconds, it has started a browser, which is what we wanted. Stop waiting for it, and return.
export async function runOpener(command: string, args: string[], graceMs = OPENER_GRACE_MS): Promise<void> {
await new Promise<void>((resolve, reject) => {
const child = spawn(command, args, { env: { ...process.env, SHELL: undefined }, detached: true, stdio: 'ignore' });
let settled = false;
const settle = (fn: () => void) => { if (settled) return; settled = true; clearTimeout(timer); fn(); };
// Still running after the grace period: it started a browser. Let go of it.
const timer = setTimeout(() => settle(() => { child.unref(); resolve(); }), graceMs);
child.once('error', (error) => settle(() => reject(error)));
child.once('exit', (code, signal) => settle(() =>
code === 0 ? resolve() : reject(new Error(`${command} exited with ${code ?? signal ?? 'unknown status'}`))));
});
}
The two places that called execFileAsync now call runOpener. I checked it the same way as the bug:
| Check | Result |
|---|---|
tsc --strict on the changed file, and an esbuild bundle |
pass |
runOpener('true') |
resolves in 4 ms |
runOpener('false') |
rejects in 3 ms, so the fallbacks run |
runOpener('no-such-binary') |
rejects with ENOENT in 37 ms, so the fallbacks run |
runOpener('sleep', ['30']) |
resolves at 3,002 ms and lets the process run on |
The small reproduction, real xdg-open, 10 s stand-in browser |
3.0 – 5.3 s instead of the browser’s whole lifetime |
There’s a second, even smaller change worth suggesting on the tool’s side: the Artifact tool doesn’t need to await
the browser at all. It could start it and log any failure, since opening a browser is a convenience and shouldn’t
decide when the result comes back. I’ll offer both and let the maintainers choose.
Before this becomes a pull request, the launcher’s existing unit tests need updating: they mock execFile, and the new
code uses spawn. That’s on my list for the PR.
Step 9: has anyone filed it already?
Before I file a bug, I search for an existing one, because a duplicate wastes the maintainers’ time and mine. I searched issues and pull
requests in QwenLM/qwen-code, open and closed, for xdg-open, openBrowserSecurely, secure-browser-launcher,
execFile detached, “Publishing artifact”, “artifact hang”, “artifact stuck”, autoOpen, WSLg and more,
plus every issue with “artifact” in the title. This launcher came from Google’s Gemini CLI, which Qwen Code is built
from, so I searched there too. No issue or pull request describes this hang. Some related ones:
- #1674: a crash when
xdg-openis missing. Same function, opposite failure, fixed by catching the error. - #4712: browser-opening commands crashing on headless Linux. The fix made browser opening best-effort, but for errors, not for time.
- PR #5557 added the Artifact tool and its auto-open, and
PR #5617 added the
artifact.autoOpensetting, which is today’s workaround.
If it happens to you
If you run Qwen Code under WSL, or on any Linux without a desktop environment:
- Turn auto-open off. Artifacts still publish to
~/.qwen/artifacts/<id>/index.html, and you open them yourself. Either setQWEN_ARTIFACT_NO_AUTO_OPEN=1before startingqwen, or add"artifact": { "autoOpen": false }to~/.qwen/settings.jsonand restart. - Or keep auto-open and set
BROWSER, for exampleexport BROWSER=google-chrome. Qwen Code then uses its own launcher, which doesn’t wait. That also changes how other Qwen Code features open links. - If a publish is already stuck, find the Chrome window it opened (check behind your other windows) and close it. The call returns right away, with success.
How I work a bug like this
Looking back, the steps above follow a pattern I use on purpose:
- Records before theories. The session log and the process table answered most of the questions before I read any code. A model’s summary, including the one in my resumed session, is not a record.
- Check the claim everyone believes. “It started recently” was mine, and it was wrong. Checking it kept me from filing a bug about a regression that isn’t one.
- Read the code that actually ran, at the exact version, and then confirm it matches
mainbefore proposing a change. - Reproduce it small, then for real. The small reproduction proves the mechanism; the full one proves it’s the same thing the user sees. Neither touches my real browser or settings.
- Measure the workaround and the fix with the same reproduction as the bug, so the numbers compare.
- Search before filing, and link what’s related, so the maintainers get context instead of a duplicate.
- Offer a fix, but keep it small and leave design choices to the people who own the code. That’s how the last one went: I filed #15600, offered a small fix, and after a week of review it was merged as PR #15681.
What’s next
I haven’t filed a bug for this yet, or opened a pull request with the fix. I’ll update this post as soon as I do.
How I tested
- Qwen Code 0.27.3 when the hang happened, and 0.27.4 (the latest on npm on November 15, 2026) for the
reproductions. Qwen Code updates itself into
~/.qwen/updatesand keeps every version, which made comparing the launcher across versions easy. - The machine: my workstation, WSL2 on Windows with Ubuntu 24.04.4 and WSLg,
XDG_CURRENT_DESKTOPunset, xdg-utils 1.1.3 with Chrome as thetext/htmlhandler, Google Chrome 156, Node 24.14. - The model was Qwen3.8-Flash-Next-FP8, running fully locally: SGLang (my own patched Docker build) on two NVIDIA
RTX PRO 6000 Blackwell GPUs with 96 GB each, split across both with tensor and expert parallelism (TP=2, EP=2), MTP
speculative decoding (3 steps, 4 draft tokens), and a 262K-token context.
qwen38-27b, in the screenshot’s status bar, is the model name myqwen38wrapper passes to Qwen Code. The model plays no part in this bug: the hang happens after its request, inside Qwen Code. - The source is the v0.27.4 tag.
mainatb098616f2f(November 15) has the same launcher; its last change was to a comment, in July. - The fix was written against
main, type-checked withtsc --strict, bundled with esbuild, and run through the small reproduction.
Sources
- Qwen Code v0.27.4:
artifact-tool.ts(the awaited auto-open),secure-browser-launcher.ts(the launcher) - #1674 and #4712: earlier browser-launch failures, both errors rather than waits
- PR #5557: the Artifact tool, and
PR #5617: the
artifact.autoOpensetting - Node.js:
child_process.execFileand thedetachedoption - xdg-utils, which provides
xdg-open