{"record":{"id":"6c7857ca56d951cf","repo":"netbirdio/netbird","slug":"xembed-x-error-ignored-s-code-d-request-d","errorCode":null,"errorMessage":"xembed: X error (ignored): %s (code=%d, request=%d.%d, resource=0x%lx)\n","messagePattern":"xembed: X error \\(ignored\\): (.+?) \\(code=(.+?), request=(.+?)\\.(.+?), resource=0x%lx\\)\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"info","filePath":"client/ui/xembed_tray_linux.c","lineNumber":29,"sourceCode":"#include <stdlib.h>\n#include <string.h>\n#include <stdio.h>\n\n#define SYSTEM_TRAY_REQUEST_DOCK 0\n#define XEMBED_MAPPED            (1 << 0)\n\n/* Xlib's default protocol-error handler calls exit() on any async X error,\n   killing the whole UI process. Handlers are process-global (not\n   per-Display), so a single install covers our raw tray Display and GDK's.\n   Tray work is full of races the X server reports asynchronously — the tray\n   manager window dying between xembed_find_tray and xembed_dock (BadWindow\n   on XSendEvent), or x11_move_window touching a popup the WM already\n   destroyed — and the default handler would take us down for any of them.\n   Returning 0 here makes the error a logged no-op instead. */\nstatic int xembed_x_error_handler(Display *dpy, XErrorEvent *ev) {\n    char buf[256];\n    XGetErrorText(dpy, ev->error_code, buf, sizeof(buf));\n    fprintf(stderr,\n            \"xembed: X error (ignored): %s (code=%d, request=%d.%d, resource=0x%lx)\\n\",\n            buf, ev->error_code, ev->request_code, ev->minor_code,\n            ev->resourceid);\n    return 0;\n}\n\n/* The I/O error handler fires when the X connection itself drops (server\n   gone, socket closed). Xlib treats this as fatal and exits even if we\n   return, so this can't keep the process alive — it only logs a clearer\n   line than Xlib's terse default before the unavoidable exit. */\nstatic int xembed_x_io_error_handler(Display *dpy) {\n    (void)dpy;\n    fprintf(stderr, \"xembed: X I/O error (connection lost)\\n\");\n    return 0;\n}\n\n/* Install the process-global handlers. Idempotent and cheap, so callers may\n   invoke it after every XOpenDisplay without tracking prior installs. */","sourceCodeStart":11,"sourceCodeEnd":47,"githubUrl":"https://github.com/netbirdio/netbird/blob/93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c/client/ui/xembed_tray_linux.c#L11-L47","documentation":"Not a failure: a stderr diagnostic printed by the custom Xlib error handler installed for the Linux tray (client/ui/xembed_tray_linux.c). It replaces Xlib's default handler, which calls exit() on any asynchronous X error; returning 0 makes the error a logged no-op so one stray protocol error cannot kill the whole UI process. The message always includes '(ignored)'.","triggerScenarios":"Asynchronous X errors from tray races the code comments name: the system-tray manager window dying between xembed_find_tray and xembed_dock (BadWindow on XSendEvent), or x11_move_window touching a popup the window manager already destroyed.","commonSituations":"GNOME/KDE tray extensions or systray daemons restarting while the NetBird UI runs; flaky StatusNotifier/XEmbed support on minimal window managers; the line appears in stderr but the tray and app keep working.","solutions":["No action needed: the error was already swallowed by design; check whether the tray icon still functions","If the tray icon vanished, restart the tray provider (extension/applet) or relaunch the UI so it re-docks","Keep xembed_install_error_handlers installed; removing it restores Xlib's exit-on-error default and makes these races fatal"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep xembed_install_error_handlers() installed after every XOpenDisplay; it is idempotent and cheap","Treat these lines as expected noise during tray-manager restarts; only investigate if the tray icon stops working","Re-dock or relaunch the UI after the tray provider comes back instead of assuming UI failure"],"tags":["x11","xlib","system-tray","linux","c"],"backgroundTag":null,"analyzedSha":"93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c","analyzedAt":"2026-08-16T03:09:19.136Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}